Advertisement
amine99

Untitled

Apr 29th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  4. #define ALL(x) x.begin(),x.end()
  5. #define SZ(x) x.size()
  6. #define PB push_back
  7. #define MP make_pair
  8. #define F first
  9. #define S second
  10. typedef long long LL;
  11. typedef vector<int> VI;
  12. typedef pair<int,int> PI;
  13.  
  14. int n,s;
  15. pair<int,int> a[101];
  16. int m[101];
  17.  
  18. int main() {
  19.    io;
  20.    cin >> n >> s;
  21.    for(int i = 0 ; i < n ; i++) {
  22.       cin >> a[i].F >> a[i].S;
  23.       m[i] = a[i].F * 60 + a[i].S;
  24.    }
  25.    if(m[0] > s) {
  26.       cout << "0 0";
  27.       return 0;
  28.    }
  29.    for(int i = 0 ; i < n-1 ; i++) {
  30.       if(m[i+1] - m[i] - 3 >= 2*s ) {
  31.          int x = m[i] + s;
  32.          cout << x / 60 << " " << x % 60+1;
  33.          return 0;
  34.       }
  35.    }
  36.    int x = m[n-1] + s;
  37.    cout << x / 60 << " " << x % 60 + 1;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement