-
Notifications
You must be signed in to change notification settings - Fork 1
/
MAXTASTE.java
48 lines (37 loc) · 1.1 KB
/
MAXTASTE.java
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
package codechef;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class MAXTASTE {
public static void main(String[] args) {
ArrayList<Integer> a = new ArrayList<>();
ArrayList<Integer> b = new ArrayList<>();
ArrayList<Integer> c = new ArrayList<>();
ArrayList<Integer> d = new ArrayList<>();
Scanner sc = new Scanner(System.in);
int cases = sc.nextInt();
sc.nextLine();
for (int i = 0; i < cases; i++) {
String[] split_in = sc.nextLine().split(" ");
a.add(Integer.parseInt(split_in[0]));
b.add(Integer.parseInt(split_in[1]));
c.add(Integer.parseInt(split_in[2]));
d.add(Integer.parseInt(split_in[3]));
}
sc.close();
for (int i = 0; i < cases; i++) {
System.out.println(getTastiness(a.get(i), b.get(i), c.get(i), d.get(i)));
}
}
public static int getTastiness(int a,int b,int c,int d) {
return max(a+c,a+d,b+c,b+d);
}
public static int max(int a,int b,int c,int d) {
ArrayList<Integer> getmax=new ArrayList<>();
getmax.add(a);
getmax.add(b);
getmax.add(c);
getmax.add(d);
return Collections.max(getmax);
}
}