<\/span><\/h2>\n\n\n\nChefland has 7<\/strong> days in a week. Chef is very conscious about his work done during the week.<\/p>\n\n\n\nThere are two ways he can spend his energy during the week. The first way is to do x<\/strong><\/em> units of work every day and the second way is to do y<\/strong><\/em> (>x<\/strong><\/em>) units of work for the first d<\/em><\/strong> (<7<\/em><\/strong>) days and to do z<\/em><\/strong> (<x<\/strong><\/em>) units of work thereafter since he will get tired of working more in the initial few days.<\/p>\n\n\n\nFind the maximum amount of work he can do during the week if he is free to choose either of the two strategies.<\/p>\n\n\n\n
<\/span>Input <\/strong><\/span><\/h2>\n\n\n\n- The first line contains an integer T<\/strong><\/em>, the number of test cases. Then the test cases follow.<\/li>
- Each test case contains a single line of input, four integers d<\/strong><\/em>, x<\/strong><\/em>, y<\/strong><\/em>, z<\/strong><\/em>.<\/li><\/ul>\n\n\n\n
<\/span>Output<\/strong><\/span><\/h2>\n\n\n\nFor each testcase, output in a single line the answer to the problem.<\/p>\n\n\n\n
<\/span>Constraints<\/strong><\/span><\/h2>\n\n\n\n- 1 \u2264 T<\/em> \u2264 5\u22c5103<\/sup><\/strong><\/li>
- 1 \u2264 d<\/em> < 7<\/strong><\/li>
- 1 \u2264 z<\/em> < x<\/em> < y<\/em> \u2264 18<\/strong><\/li><\/ul>\n\n\n\n
Subtasks<\/strong><\/p>\n\n\n\nSubtask #1 (100 points): <\/strong>Original constraints<\/p>\n\n\n\nSample Input<\/strong><\/p>\n\n\n\n3\n1 2 3 1\n6 2 3 1\n1 2 8 1<\/code><\/pre>\n\n\n\nSample Output<\/strong><\/p>\n\n\n\n14\n19\n14<\/code><\/pre>\n\n\n\n<\/span>Explanation<\/strong><\/span><\/h2>\n\n\n\nTest Case 1:<\/strong> Using the first strategy, Chef does 2\u22c57 = 14<\/strong> units of work and using the second strategy Chef does 3\u22c51 + 1\u22c56 = 9<\/strong> units of work. So the maximum amount of work that Chef can do is max(14,9) = 14<\/strong> units by using the first strategy.<\/p>\n\n\n\nTest Case 2:<\/strong> Using the first strategy, Chef does 2\u22c57 = 14<\/strong> units of work and using the second strategy Chef does 3\u22c56 + 1\u22c51 = 19 <\/strong>units of work. So the maximum amount of work that Chef can do is max(14,19) = 19 <\/strong>units by using the second strategy.<\/p>\n\n\n\n<\/span>Solution – Maximum Production<\/strong><\/span><\/h2>\n\n\n\n<\/span>C++<\/strong><\/span><\/h3>\n\n\n\n#include <iostream>\nusing namespace std;\n\nint main() {\n\t\/\/ your code goes here\n\tint t; cin >> t;\n\twhile(t--){\n\t \n\t int d,x,y,z;\n\t cin >> d >> x >> y >> z;\n\t int way1 = 7*x;\n\t int way2 = ((d*y)+((7-d)*z));\n\t \n\t cout << max(way1,way2) << \"\\n\";\n\t \n\t}\n\treturn 0;\n}\n<\/pre>\n\n\n\n