Advertisement
amine99

Untitled

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