SHARE
TWEET

Untitled

a guest Dec 8th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5.  
  6. signed main() {
  7.     int t;
  8.     cin >> t;
  9.  
  10.     array<string, 12> MONTHS = {
  11.         "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  12.     };
  13.     for (int test = 1; test <= t; ++test) {
  14.         cout << "Case #" << test <<": ";
  15.         int n;
  16.         cin >> n;
  17.         pair<int, string> d[n];
  18.         for (int i = 0; i < n; ++i) {
  19.             string month, day;
  20.             cin >> month >> day;
  21.             int k;
  22.             if ('1' <= day[1] && day[1] <= '9')
  23.                 k = (day[0] - '0') * 10 + (day[1] - '0');
  24.             else
  25.                 k = day[0] - '0';
  26.             for (int j = 0; j < 12; ++j)
  27.                 if (MONTHS[j] == month) {
  28.                     k += j * 100;
  29.                     break;
  30.                 }
  31.             d[i] = {k, month + " " + day};
  32.         }
  33.  
  34.         string month, day;
  35.         cin >> month >> day;
  36.         int k;    
  37.         if ('1' <= day[1] && day[1] <= '9')
  38.                 k = (day[0] - '0') * 10 + (day[1] - '0');
  39.             else
  40.                 k = day[0] - '0';
  41.             for (int i = 0; i < 12; ++i)
  42.                 if (MONTHS[i] == month) {
  43.                     k += i * 100;
  44.                     break;
  45.                 }
  46.         sort(d, d + n);
  47.         string z = "z";
  48.         int x = upper_bound(d, d + n, make_pair(k, z)) - d;
  49.         if (x == n)
  50.             cout << "See you next year";
  51.         else
  52.             cout << d[x].second;
  53.         cout << endl;
  54.     }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top