-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path241122-10825.java
64 lines (55 loc) · 1.86 KB
/
241122-10825.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
Student[] students = new Student[N];
for (int i = 0; i < N; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
String name = st.nextToken();
int korean = Integer.parseInt(st.nextToken());
int english = Integer.parseInt(st.nextToken());
int math = Integer.parseInt(st.nextToken());
students[i] = new Student(name, korean, english, math);
}
Arrays.sort(students, (o1, o2) -> {
if (o1.korean > o2.korean) {
return -1;
} else if (o1.korean < o2.korean) {
return 1;
}
if (o1.english < o2.english) {
return -1;
} else if (o1.english > o2.english) {
return 1;
}
if (o1.math > o2.math) {
return -1;
} else if (o1.math < o2.math) {
return 1;
}
return o1.name.compareTo(o2.name);
});
StringBuilder sb = new StringBuilder();
for (int i = 0; i < N; i++) {
sb.append(students[i].name).append("\n");
}
System.out.print(sb);
}
static class Student {
String name;
int korean;
int english;
int math;
public Student(String name, int korean, int english, int math) {
this.name = name;
this.korean = korean;
this.english = english;
this.math = math;
}
}
}