package AdvancedLevelPractice;
import java.util.Scanner;
public class pat1006 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
int M = scanner.nextInt();
String[] nameStrings = new String[M];
String[] unlockStrings = new String[M];
String[] lockStrings = new String[M];
for(int i = 0; i < M; i++){
nameStrings[i] = scanner.next();
unlockStrings[i] = scanner.next();
lockStrings[i] = scanner.next();
}
int unlock = getUnlock(unlockStrings);
int lock = getLock(lockStrings);
System.out.print(nameStrings[unlock]+" "+nameStrings[lock]);
scanner.close();
}
private static int getLock(String[] lockStrings) {
// TODO Auto-generated method stub
String[] timeStrings = lockStrings[0].split(":");
int[] time = new int[3];
for(int i = 0; i < 3; i++){
time[i] = Integer.parseInt(timeStrings[i]);
}
int index = 0;
for(int i = 1; i < lockStrings.length; i++){
String[] tmpStrings = lockStrings[i].split(":");
for(int j = 0; j < 3; j++){
if(Integer.parseInt(tmpStrings[j]) > time[j]){
time[0] = Integer.parseInt(tmpStrings[0]);
time[1] = Integer.parseInt(tmpStrings[1]);
time[2] = Integer.parseInt(tmpStrings[2]);
index = i;
break;
}
}
}
return index;
}
private static int getUnlock(String[] unlockStrings) {
// TODO Auto-generated method stub
String[] timeStrings = unlockStrings[0].split(":");
int[] time = new int[3];
for(int i = 0; i < 3; i++){
time[i] = Integer.parseInt(timeStrings[i]);
}
int index = 0;
for(int i = 1; i < unlockStrings.length; i++){
String[] tmpStrings = unlockStrings[i].split(":");
for(int j = 0; j < 3; j++){
if(Integer.parseInt(tmpStrings[j]) < time[j]){
time[0] = Integer.parseInt(tmpStrings[0]);
time[1] = Integer.parseInt(tmpStrings[1]);
time[2] = Integer.parseInt(tmpStrings[2]);
index = i;
break;
}
}
}
return index;
}
}
pat1006
最新推荐文章于 2022-09-08 00:38:01 发布