-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSXThoiGian.java
More file actions
62 lines (51 loc) · 1.66 KB
/
Copy pathSXThoiGian.java
File metadata and controls
62 lines (51 loc) · 1.66 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
59
60
61
62
import java.util.*;
public class SXThoiGian {
public static class ThoiGian implements Comparable<ThoiGian> {
private int hour;
private int minute;
private int second;
public ThoiGian() {
this.hour = 0;
this.minute = 0;
this.second = 0;
}
public ThoiGian(int hour, int minute, int second) {
this.hour = hour;
this.minute = minute;
this.second = second;
}
public int getHour() {
return this.hour;
}
public int getMinute() {
return this.minute;
}
public int getSecond() {
return this.second;
}
@Override
public int compareTo(ThoiGian thoiGian) {
return (this.hour * 3600 + this.minute * 60 + this.second)
- (thoiGian.hour * 3600 + thoiGian.minute * 60 + thoiGian.second);
}
}
public static Scanner in = new Scanner(System.in);
public static void testcase() {
List<ThoiGian> thoiGian = new ArrayList<>();
int t = Integer.parseInt(in.nextLine());
for (int i = 1; i <= t; i++) {
int h = in.nextInt();
int m = in.nextInt();
int s = in.nextInt();
thoiGian.add(new ThoiGian(h, m, s));
}
Collections.sort(thoiGian);
for (ThoiGian x : thoiGian) {
System.out.print(x.getHour() + " " + x.getMinute() + " " + x.getSecond());
System.out.println();
}
}
public static void main(String args[]) {
testcase();
}
}