Moneymanager
SRM 691 · 2016-05-02 · by subscriber
Problem Statement
- First, his work on the project increases his experience by a[i].
- Then, when the project is done, he earns money for the project. The amount earned is (b[i] * E), where E is his total amount of experience at the moment of finishing the project.
Constraints
- Number of elements in a will be between 2 and 50, inclusive.
- Number of elements in a will be even.
- a and b will contain the same number of elements.
- Each element in a will be between 1 and 100,000, inclusive.
- Each element in b will be between 1 and 10, inclusive.
- X will be between 0 and 100,000, inclusive.
{1,1}
{2,1}
0
Returns: 5
An optimal solution: Hero works on project #1 (zero-based index). He first gains 1 experience and then he makes 1*1 = 1 money. Hero goes to the training camp and gains X=0 experience. Hero works on project #0. He first gains 1 experience and then he makes 2*2 = 4 money. The total amount of money earned during this solution is 1 + 4 = 5.
{1,1}
{1,5}
10
Returns: 61
An optimal solution: Hero works on project #0. He first gains 1 experience and then he makes 1*1 = 1 money. Hero goes to the training camp and gains 10 experience. Hero works on project #1. He first gains 1 experience and then he makes 5*12 = 60 money. The total amount of money earned during this solution is 1 + 60 = 61.
{4,4,6,6}
{2,2,3,3}
100
Returns: 726
One optimal solution: project #0, project #1, training camp, project #3, project #2.
{44,68,47,81,34,91,24,5,85,59,7,9,100,18,6,34,1,79,91,99,60,2,24,85,96,11,40,13,30,89,74,78,72,13,14,33,96,69,14,18,14,63,95,71,87,57}
{7,4,4,4,1,7,6,5,3,7,2,7,3,1,3,3,3,1,2,7,3,1,5,7,2,1,6,4,3,1,5,6,2,7,5,4,3,7,5,1,6,6,4,6,4,5}
40
Returns: 327332
{43,97,33,97,77,57,67,84,45,30,13,3,3,73,72,49,36,91,11,24,68,76,47,24,37,12,27,98,70,73,29,56}
{5,1,6,3,4,4,3,5,4,4,5,5,5,3,3,6,5,4,5,4,2,7,2,4,3,5,5,2,2,3,5,6}
29
Returns: 159618
Submissions are judged against all 89 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Moneymanager with a public method int getbest(vector<int> a, vector<int> b, int X) · 89 test cases · 2 s / 256 MB per case