-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathluyentaplaptrinh.java
More file actions
51 lines (45 loc) · 1.28 KB
/
Copy pathluyentaplaptrinh.java
File metadata and controls
51 lines (45 loc) · 1.28 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
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
class ThiSinh implements Comparable<ThiSinh> {
String ten;
int ac;
int submit;
ThiSinh(String ten, int ac, int submit) {
this.ten = ten;
this.ac = ac;
this.submit = submit;
}
public int compareTo(ThiSinh o) {
if (this.ac != o.ac) {
return o.ac - this.ac;
}
if (this.submit != o.submit) {
return this.submit - o.submit;
}
return this.ten.compareTo(o.ten);
}
@Override
public String toString() {
return ten + " " + ac + " " + submit;
}
}
public class Luyentaplaptrinh {
public static void main(String[] args) throws FileNotFoundException {
Scanner sc = new Scanner(new File("LUYENTAP.in"));
int n = sc.nextInt();
ArrayList<ThiSinh> list = new ArrayList<ThiSinh>();
for (int i = 0; i < n; i++) {
sc.nextLine();
String ten = sc.nextLine();
int ac = sc.nextInt();
int submit = sc.nextInt();
list.add(new ThiSinh(ten, ac, submit));
}
Collections.sort(list);
for (int i = 0; i < n; i++) {
System.out.println(list.get(i));
}
sc.close();
}
}