fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct User{
  5. int id, bd;
  6. };
  7.  
  8. const int N = 1e6+5;
  9. struct User user[N];
  10.  
  11. int dd(int bd){
  12. return bd/1000000;
  13. }
  14.  
  15. int mm(int bd){
  16. return (bd % 1000000) / 10000;
  17. }
  18.  
  19. int yy(int bd){
  20. return bd % 10000;
  21. }
  22.  
  23. int ss(int maxi, int bd){
  24. if (yy(bd) > yy(maxi)){
  25. return bd;
  26. }else if(yy(bd) == yy(maxi)){
  27. if (mm(bd) > mm(maxi)){
  28. return bd;
  29. }else if(mm(bd) == mm(maxi)){
  30. if (dd(bd) > dd(maxi)){
  31. return bd;
  32. }
  33. return maxi;
  34. }
  35. return maxi;
  36. }
  37. return maxi;
  38. }
  39.  
  40. int main(){
  41. int n; cin >> n;
  42. for(int i = 1; i <= n;i++){
  43. cin >> user[i].id >> user[i].bd;
  44. }
  45. if (n == 0){
  46. cout << "EMPTY";
  47. return 0;
  48. }
  49. int maxi = user[0].bd;
  50. for(int i = 1;i <= n;i++){
  51. maxi = ss(maxi, user[i].bd);
  52. }
  53. if (dd(maxi) < 10){
  54. cout << "0";
  55. }
  56. cout << dd(maxi) << "-";
  57. if (mm(maxi) < 10){
  58. cout << "0";
  59. }
  60. cout << mm(maxi) << "-";
  61. if (yy(maxi) < 10){
  62. cout << "0";
  63. }
  64. cout << yy(maxi);
  65.  
  66. }
  67.  
Success #stdin #stdout 0.01s 5320KB
stdin
3
1 20031990
2 20031990
3 20031999
stdout
20-03-1999