-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProba de rezistenta.java
More file actions
43 lines (42 loc) · 1.21 KB
/
Proba de rezistenta.java
File metadata and controls
43 lines (42 loc) · 1.21 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
import java.util.*;
public class Eccpr{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
ArrayList<Elevi>list = new ArrayList<>();
int n = sc.nextInt();
for(int i=0;i<n;i++){
list.add(new Elevi(sc.next(),sc.next(),sc.nextInt()));
}
int cnt=0;
int nr = sc.nextInt();
Collections.sort(list, new Comparator<Elevi>(){
@Override
public int compare(Elevi a, Elevi b){
if(a.timp>=b.timp){
return 1;
}else return -1;
}
});
for(int i=0;i<list.size();i++){
if(list.get(i).timp<=nr){
cnt++;
}
}
System.out.println(cnt);
for(int i=0;i<list.size();i++){
if(list.get(i).timp<=nr){
System.out.println(list.get(i).nume+" "+list.get(i).prenume+" "+list.get(i).timp);
}
}
}
}
public class Elevi{
String nume;
String prenume;
int timp;
Elevi(String nume, String prenume, int timp){
this.nume=nume;
this.prenume=prenume;
this.timp=timp;
}
}