# Maximum Production | CodeChef Solution

Hello coders, today we are going to solve Maximum Production CodeChef Solution whose Problem Code is EITA.

Contents

Chefland has 7 days in a week. Chef is very conscious about his work done during the week.

There are two ways he can spend his energy during the week. The first way is to do x units of work every day and the second way is to do y (>x) units of work for the first d (<7) days and to do z (<x) units of work thereafter since he will get tired of working more in the initial few days.

Find the maximum amount of work he can do during the week if he is free to choose either of the two strategies.

## Input

• The first line contains an integer T, the number of test cases. Then the test cases follow.
• Each test case contains a single line of input, four integers d, x, y, z.

## Output

For each testcase, output in a single line the answer to the problem.

## Constraints

• 1 ≤ T ≤ 5⋅103
• 1 ≤ d < 7
• 1 ≤ z < x < y ≤ 18

Subtask #1 (100 points): Original constraints

Sample Input

``````3
1 2 3 1
6 2 3 1
1 2 8 1``````

Sample Output

``````14
19
14``````

## Explanation

Test Case 1: Using the first strategy, Chef does 2⋅7 = 14 units of work and using the second strategy Chef does 3⋅1 + 1⋅6 = 9 units of work. So the maximum amount of work that Chef can do is max(14,9) = 14 units by using the first strategy.

Test Case 2: Using the first strategy, Chef does 2⋅7 = 14 units of work and using the second strategy Chef does 3⋅6 + 1⋅1 = 19 units of work. So the maximum amount of work that Chef can do is max(14,19) = 19 units by using the second strategy.

## Solution – Maximum Production

### C++

```#include <iostream>
using namespace std;

int main() {
int t; cin >> t;
while(t--){

int d,x,y,z;
cin >> d >> x >> y >> z;
int way1 = 7*x;
int way2 = ((d*y)+((7-d)*z));

cout << max(way1,way2) << "\n";

}
return 0;
}
```

### Java

```/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int d,x,y,z;
d = sc.nextInt();
x = sc.nextInt();
y =  sc.nextInt();
z = sc.nextInt();
int ans = 0;
ans = Math.max(7*x,((d*y)+((7-d)*z)));
System.out.println(ans);
}

}
}
```

### Python

```# cook your dish here
T = int(input())
for i in range(T):
d, x, y, z = map(int, input().split())
first_result = x * 7
second_result = (y*d)+((7-d)*z)
result = [first_result, second_result]
largest_number = max(result)
print(largest_number)
```

Disclaimer: The above Problem (Maximum Production) is generated by CodeChef but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.