Skip to content

Commit 1066598

Browse files
committed
Codechef July long challenge problem A solution
1 parent 7783b32 commit 1066598

File tree

1 file changed

+32
-0
lines changed
  • Codechef/JulyLongChallenge2021

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package JulyLongChallenge2021;
2+
3+
import java.util.Scanner;
4+
5+
public class A {
6+
7+
public static void main(String[] args) {
8+
9+
Scanner sc = new Scanner(System.in);
10+
11+
int t = sc.nextInt();
12+
13+
for (int tt = 0; tt < t; tt++) {
14+
int d = sc.nextInt();
15+
int x = sc.nextInt();
16+
int y = sc.nextInt();
17+
int z = sc.nextInt();
18+
19+
int ans = maximumProduction(d, x, y, z);
20+
21+
System.out.println(ans);
22+
}
23+
sc.close();
24+
}
25+
26+
private static int maximumProduction(int d, int x, int y, int z) {
27+
int ans1 = 7 * x;
28+
int remainingDays = 7 - d;
29+
int ans2 = (y * d) + (z * remainingDays);
30+
return Math.max(ans1, ans2);
31+
}
32+
}

0 commit comments

Comments
 (0)