-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaximiseTheTasiness.java
More file actions
55 lines (44 loc) · 1.41 KB
/
MaximiseTheTasiness.java
File metadata and controls
55 lines (44 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Maximise the Tastiness
Chef is making a dish that consists of exactly two ingredients. He has four ingredients A, B, C and D with tastiness a, b, c, and d respectively. He can use either A or B as the first ingredient and either C or D as the second ingredient.
The tastiness of a dish is the sum of tastiness of its ingredients. Find the maximum possible tastiness of the dish that the chef can prepare.
Input Format
The first line of input will contain a single integer T, denoting the number of test cases.
The first and only line of each test case contains four space-separated integers a, b, c, and d — the tastiness of the four ingredients.
Output Format
For each test case, output on a new line the maximum possible tastiness of the dish that chef can prepare.
Constraints
1 ≤ T ≤ 100
1 ≤ a, b, c, d ≤ 100
Sample 1:
Input
2
3 5 6 2
16 15 5 4
Output
11
21
*/
import java.util.*;
public class MaximiseTheTasiness {
public static void main(String[] args) {
// your code goes here
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
ArrayList<Integer> num1 = new ArrayList<Integer>();
int a = sc.nextInt();
int b = sc.nextInt();
num1.add(a);
num1.add(b);
int c = Collections.max(num1);
int d = sc.nextInt();
int e = sc.nextInt();
num1.clear();
num1.add(d);
num1.add(e);
int f = Collections.max(num1);
System.out.println(c + f);
}
}
}