-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProm_11.java
More file actions
58 lines (48 loc) · 1.32 KB
/
Prom_11.java
File metadata and controls
58 lines (48 loc) · 1.32 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
56
57
58
package com.ad;
import java.util.*;
import java.io.FileInputStream;
public class Prom_11 {
/**
* @param args
* 심해 탐사 - 기출
*/
static int N, M, W, Answer;
static int[][] S;
public static void main(String[] args)throws Exception {
// TODO Auto-generated method stub
System.setIn(new FileInputStream("src/data/prom11"));
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int test_case = 1; test_case <= T; test_case++){
/////////////////////////////////////////////////////////
N = sc.nextInt();
S = new int[10000][2];
int[] sort = new int [N];
for (int i = 0; i < N; i++) {
S[i][0] = sc.nextInt();
S[i][1] = sc.nextInt();
sort[i] = S[i][1]*10000+S[i][0];
sort[i] = S[i][1]*10000+S[i][0];
//System.out.println(sort[i]);
}
Arrays.sort(sort);
for (int i = 0; i < sort.length; i++) {
System.out.println(sort[i]);
}
int sum = 0;
Answer = 0;
int max = Integer.MIN_VALUE;
for (int i = 0; i < N; i++) {
int a = sort[i]/10000;
int b = sort[i]%10000;
sum += b;
//System.out.println(sum-a);
if(sum-a > max) {
max = sum-a;
}
}
System.out.println(max);
/////////////////////////////////////////////////////////
} // end for
} // end main
}