Maximum Points solution codechef starters 12

Maximum Points solution codechef starters 12

Cooking Examinations Authority (C.E.A.) is conducting an Ordinary Cooking Level (O.C.L.) test, which tests the candidate skills on three different aspects – Appearance, Flavor and Texture. Chef is planning to appear in this coveted test.

O.C.L. is a 240240 minuteminute test consisting of 2020 problemsproblems on each aspecteach aspect (and hence total 6060 problems).

Chef figured out that for eacheach problem on Appearance, Flavor and Texture

  • He requires A,BA,B and CC minutes respectively to correctly solve that problem.
  • He will be awarded X,YX,Y and ZZ points respectively when correctly solved that problem.

Chef wonders what are the maximum points PP that he can get in O.C.L.? Can you help the Chef?

Input Format

  • The first line of input contains a single integer TT, denoting the number of testcases. The description of the TT testcases follows.
  • The first line of each testcase contains 33 space separated integers A,BA,B and CC.
  • The second line of each testcase contains 33 space separated integers X,YX,Y and ZZ.

Output Format

For each testcase, output a single line containing an integer PP, which denotes the maximum points that the Chef can score in O.C.L.


  • 1T1001≤T≤100
  • 1A,B,C101≤A,B,C≤10
  • 1X,Y,Z1061≤X,Y,Z≤106

Sample Input 1 

4 4 4
5 5 5
5 5 5
10 8 6
5 6 7
5 6 7

Sample Output 1 



Test Case 11: Chef can correctly solve all the problems within the time limit, resulting in total 300300 points.

Test Case 22: Chef can correctly solve 2020 problems on Appearance, 2020 problems on Flavor and 88 problems on Texture, resulting in total 408408 points. We can prove that the Chef cannot get more than 408408 points.

Leave a Comment