SHARE
TWEET

Untitled

a guest Feb 27th, 2020 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef pair <int, int> pii;
  6.  
  7. #define pb push_back
  8. #define mp make_pair
  9.  
  10. int main(){
  11.  
  12.     int n, i, j;
  13.     vector <pii> v;
  14.     cin >> n;
  15.     vector <int> x(n), y(n);
  16.     for(i = 0; i < n; i++){
  17.         cin >> x[i];
  18.     }
  19.     for(i = 0; i < n; i++){
  20.         cin >> y[i];
  21.     }
  22.     for(i = 0; i < n; i++){
  23.         int l = 999999, r = -1;
  24.         for(j = 0; j < 60; j++){
  25.             if((j+x[i])/60 == y[i]){
  26.                 l = min(j, l);
  27.                 r = j;
  28.             }
  29.         }
  30.         if(r == -1){
  31.             cout << "-1 -1";
  32.             return 0;
  33.         }
  34.         v.pb(mp(l, r));
  35.     }
  36.     int l = v[0].first, r = v[0].second;
  37.     for(i = 1; i < n; i++){
  38.         int tl = v[i].first, tr = v[i].second;
  39.         if(tr < l || tl > r || r < tl || l > tr){
  40.             cout << "-1 -1";
  41.             return 0;
  42.         }
  43.         l = max(l, tl);
  44.         r = min(r, tr);
  45.     }
  46.     cout << l << ' ' << r;
  47.  
  48.     return 0;
  49. }
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