-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ05029.java
62 lines (53 loc) · 1.72 KB
/
J05029.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
import java.util.*;
class DoanhNghiep {
private String ma, ten;
private int soLuong;
public DoanhNghiep(String ma, String ten, int soLuong) {
this.ma = ma;
this.ten = ten;
this.soLuong = soLuong;
}
public String getMa() {
return ma;
}
public int getSoLuong() {
return soLuong;
}
public String toString() {
return this.ma + " " + this.ten + " " + this.soLuong;
}
}
public class J05029 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine();
ArrayList<DoanhNghiep> a = new ArrayList<>();
for (int i = 1; i <= t; i++) {
DoanhNghiep x = new DoanhNghiep(sc.nextLine(), sc.nextLine(), sc.nextInt());
sc.nextLine();
a.add(x);
}
Collections.sort(a, new Comparator<DoanhNghiep>() {
@Override
public int compare(DoanhNghiep o1, DoanhNghiep o2) {
if (o1.getSoLuong() != o2.getSoLuong()) {
return o2.getSoLuong() - o1.getSoLuong();
} else {
return o1.getMa().compareTo(o2.getMa());
}
}
});
int q = sc.nextInt();
while (q-- > 0) {
int start = sc.nextInt();
int end = sc.nextInt();
System.out.println("DANH SACH DOANH NGHIEP NHAN TU " + start + " DEN " + end + " SINH VIEN:");
for (DoanhNghiep x : a) {
if (x.getSoLuong() <= end && x.getSoLuong() >= start) {
System.out.println(x);
}
}
}
}
}