-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoj10814.java
More file actions
46 lines (42 loc) · 1.12 KB
/
Boj10814.java
File metadata and controls
46 lines (42 loc) · 1.12 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
public class Boj10814 {
public static class Member{
int num;
String name;
public Member(int num, String name) {
super();
this.num = num;
this.name = name;
}
@Override
public String toString() {
return this.num + " "+this.name;
}
}
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
Member[] arr = new Member[N];
for(int i=0; i<N;i++) {
String[] data = br.readLine().split(" ");
arr[i] = new Member(Integer.parseInt(data[0]), data[1]);
}
Arrays.sort(arr, new Comparator<Member>() {
@Override
public int compare(Member o1, Member o2) {
return o1.num - o2.num;
}
});
for(int i=0; i<N;i++) {
sb.append(arr[i]).append("\n");
}
System.out.println(sb);
}//main
}//class