Contents

*Maximum Production Codechef Solution*

*Maximum Production Codechef Solution*

Chefland has 77 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 xx units of work every day and the second way is to do yy (>x>x) units of work for the first dd (<7<7) days and to do zz (<x<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.

See Also : July Long Challenge 2021 Solutions Codechef

### Input

- The first line contains an integer TT, the number of test cases. Then the test cases follow.
- Each test case contains a single line of input, four integers dd, xx, yy, zz.

### Output

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

### Constraints

- 1≤T≤5⋅1031≤T≤5⋅103
- 1≤d<71≤d<7
- 1≤z<x<y≤181≤z<x<y≤18

### Subtasks

**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 11:** Using the first strategy, Chef does 2⋅7=142⋅7=14 units of work and using the second strategy Chef does 3⋅1+1⋅6=93⋅1+1⋅6=9 units of work. So the maximum amount of work that Chef can do is max(14,9)=14max(14,9)=14 units by using the first strategy.

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

*Solution*

*Solution*

*Program Python:*

```
t=int(input())
for _ in range(t):
d,x,y,z = map(int,input().split())
a= x*7
b= (y*d + (7-d)*z)
print(max(a,b))
```

*August Long Challenge 2021 Solutions*

*August Long Challenge 2021 Solutions*

*Olympics Ranking**Problem Difficulties**Chef and Bulb Invention**Array Filling**Special Triplets**Geometry 1**Charge Scheduling**Chef and Digits of Large Numbers**Fat Hut**Alternating LG Queries*

*July Long Challenge 2021 Solutions*

*July Long Challenge 2021 Solutions*