-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path_10814.java
More file actions
47 lines (42 loc) ยท 1.09 KB
/
_10814.java
File metadata and controls
47 lines (42 loc) ยท 1.09 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
package backjoon;
// https://www.acmicpc.net/problem/10814
// ๋์ด์์ ๋ ฌ
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
public class _10814 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// memory 62992 runtime 2084
int N = Integer.parseInt(br.readLine());
String[][] arr = new String[N][2];
for(int i=0; i<N; i++) {
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
arr[i][0] = st.nextToken();
arr[i][1] = st.nextToken();
}
Arrays.sort(arr, new Comparator<String[]>() {
@Override
public int compare(String[] o1, String[] o2) {
return Integer.parseInt(o1[0]) - Integer.parseInt(o2[0]); //๋์ด๋ง ๋น๊ต
}
});
for(int i=0; i<N; i++){
System.out.println(arr[i][0] + " " + arr[i][1]);
}
}
}
/*
INPUT
3
21 Junkyu
21 Dohyun
20 Sunyoung
OUTPUT
20 Sunyoung
21 Junkyu
21 Dohyun
*/