-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ05033_SapXepThoiGian.java
45 lines (39 loc) · 1.15 KB
/
J05033_SapXepThoiGian.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
//B21DCCN441 codeptraikhong =))
import java.io.*;
import java.util.*;
import java.math.*;
class ThoiGian {
public int a, b, c;
public ThoiGian(int a, int b, int c) {
this.a = a;
this.b = b;
this.c = c;
}
public void print() {
System.out.println(a + " " + b + " " + c);
}
}
public class J05033_SapXepThoiGian {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
ArrayList<ThoiGian> a = new ArrayList<>();
for (int i = 0; i < n; i++) {
a.add(new ThoiGian(sc.nextInt(), sc.nextInt(), sc.nextInt()));
}
Collections.sort(a, new Comparator<ThoiGian>() {
@Override
public int compare(ThoiGian t, ThoiGian t1) {
if (t.a != t1.a) {
return t.a > t1.a ? 1 : -1;
} else if (t.b != t1.b) {
return t.b > t1.b ? 1 : -1;
}
return t.c > t1.c ? 1 : -1;
}
});
for (ThoiGian t : a) {
t.print();
}
}
}