-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGhisee.java
More file actions
55 lines (53 loc) · 1.71 KB
/
Ghisee.java
File metadata and controls
55 lines (53 loc) · 1.71 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
public class Cinema{
int h,m,p;
String n;
Cinema(int h, int m, int p, String n){
this.h=h;
this.m=m;
this.p=p;
this.n=n;
}
}
import java.util.*;
public class Eccpr{
public static void main(String [] args){
int h,m,p;
String n;
Scanner sc = new Scanner(System.in);
ArrayList<Cinema>list=new ArrayList<>();
String s=sc.next();
int hh=Integer.parseInt(s.substring(0,2));
int mm=Integer.parseInt(s.substring(3));
int x=sc.nextInt();
for(int i=0;i<x;i++){
s=sc.next();
h=Integer.parseInt(s.substring(0,2));
m=Integer.parseInt(s.substring(3));
if(h>hh){
list.add(new Cinema(h,m,sc.nextInt(),sc.nextLine()));
}else if(h==hh){
if(m>=mm){
list.add(new Cinema(h,m,sc.nextInt(),sc.nextLine()));
}else{sc.nextInt();sc.nextLine();}
}else{sc.nextInt();sc.nextLine();}
}
Collections.sort(list,new Comparator<Cinema>(){
@Override
public int compare(Cinema f1, Cinema f2){
if(f1.h>f2.h){
return 1;
}else if(f1.h==f2.h){
if(f1.m>f2.m){
return 1;
}else if(f1.m==f2.m){
if(f1.p>f2.p){
return 1;
}
else return -1;
}else return -1;
}else return -1;
}
});
System.out.println(list.get(0).n);
}
}