Untitled
unknown
plain_text
4 years ago
2.7 kB
12
Indexable
J05055/Athlete.java
public class Athlete{
private String id,name;
private Integer stt,realtime,time,priority;
public Athlete(String id, String name, String dof, String start, String end ){
this.id = id;
this.name = name;
String[] tmp = dof.split("/");
int age = 2021 - Integer.parseInt(tmp[2]);
if(age >= 32) this.priority = 3;
else if(age >= 25) this.priority = 2;
else if(age >= 18) this.priority = 1;
else this.priority = 0;
Integer x = stoi(start);
Integer y = stoi(end);
this.realtime = y -x;
this.time = this.realtime - this.priority;
}
public void setStt(Integer stt){
this.stt = stt;
}
public Integer getTime(){
return this.time;
}
private Integer stoi(String t){
Integer res = 0;
String[] tmp = t.trim().split(":");
res = Integer.parseInt(tmp[0])*3600 + Integer.parseInt(tmp[1])*60 + Integer.parseInt(tmp[2]);
return res;
}
private String itos(Integer t){
String h = Integer.toString(t/3600);
if(t/3600 <10) h = "0" +h;
t = t % 3600;
String m = Integer.toString(t/60);
if(t/60 < 10) m = "0" + m;
t %= 60;
String s = Integer.toString(t);
if(t < 10) s = "0" +s;
return h+":"+m+":"+s;
}
public String toString(){
String rt = itos(this.realtime);
String p = itos(this.priority);
String t = itos(this.time);
return id + " " + name + " " + rt + " " + p + " " + t + " " + stt;
}
}
J05055/Main.java
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = Integer.parseInt(sc.nextLine());
ArrayList < Athlete > res = new ArrayList<>();
for( int loop = 1 ; loop <= t ; loop++){
String stt = Integer.toString(loop);
if(loop < 10) stt = "VDV0" +stt;
else stt = "VDV" +stt;
res.add( new Athlete(stt,sc.nextLine() , sc.nextLine() , sc.nextLine() ,sc.nextLine() )) ;
}
int[] tmp = new int[t];
for(int i = 0 ; i < t ;i++){
tmp[i] = res.get(i).getTime();
}
Arrays.sort(tmp);
for(Athlete a : res){
for(int i = 0 ; i < t ; i ++){
if(tmp[i] == a.getTime()){
a.setStt(i+1);
break;
}
}
System.out.println(a);
}
sc.close();
}
}
/*
3
Nguyen Van Thanh
20/03/1990
07:00:00
07:10:01
Nguyen Hoa Binh
01/10/1993
07:02:00
07:11:20
Le Thanh Van
15/03/1998
07:05:00
07:15:30
*/
Editor is loading...