-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjumbo.java
More file actions
24 lines (24 loc) · 751 Bytes
/
jumbo.java
File metadata and controls
24 lines (24 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.io.*; import java.util.*;
public class jumbo
{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
int t = Integer.parseInt(br.readLine());
while(t-->0){
int n = Integer.parseInt(br.readLine());
long sum = 0;
long max = 0;
long side = 0;
for(int i=0; i<n; i++){
StringTokenizer st = new StringTokenizer(br.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
max=Math.max(Math.max(a, b), max);
side+=Math.min(a, b);
}
pw.println(side*2+max*2);
}
pw.close();
}
}