题目描述
JAVA版本
使用了两个有序map,一个正序一个逆序,存进去取第一个。
样例
import java.util.Scanner;
import java.util.Comparator;
import java.util.TreeMap;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int m = Integer.parseInt(scanner.nextLine());
TreeMap<String,String> signInMap = new TreeMap<>();
TreeMap<String,String> signOutMap = new TreeMap<>(Comparator.reverseOrder());
for (int i = 0; i < m; i++) {
String s = scanner.nextLine();
String[] split = s.split(" ");
signInMap.put(split[1],split[0]);
signOutMap.put(split[2],split[0]);
}
scanner.close();
String signIn = signInMap.firstEntry().getValue();
String signOut = signOutMap.firstEntry().getValue();
System.out.println(signIn+" "+signOut);
}
}