fork download
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner(System.in);
  7. int n = sc.nextInt();
  8. int[] total = new int[n];
  9. String[] array = new String[n];
  10. int[] sub = new int[n];
  11.  
  12. for (int i = 0 ; i < n ; i++) {
  13. String name = sc.next();
  14. int d = sc.nextInt();
  15. int m = sc.nextInt();
  16. int y = sc.nextInt();
  17. total[i] = (y * 365) + (m * 30) + d;
  18. array[i] = name;
  19. sub[i] = (y * 365) + (m * 30) + d;
  20. }
  21.  
  22. Arrays.sort(total);
  23.  
  24. for (int i = 0 ; i < n ; i++) {
  25. if (total[n-1] == sub[i]) {
  26. System.out.println(array[i]);
  27. } else if (total[0] == sub[i]) {
  28. System.out.println(array[i]);
  29. }
  30. }
  31. }
  32. }
Success #stdin #stdout 0.12s 53472KB
stdin
3
A 31 1 2000
B 1 2 2000
C 2 2 2000
stdout
A
B
C