Advertisement
amine99

Untitled

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