Advertisement
ivangarvanliev

Untitled

Jun 3rd, 2024
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. const int N = 109;
  7.  
  8. int t;
  9. int n;
  10. int s[N], e[N];
  11.  
  12. int main() {
  13.     cin >> t;
  14.     for (int tc = 0; tc < t; ++tc) {
  15.         cin >> n;
  16.         for (int i = 0; i < n; ++i) {
  17.             cin >> s[i] >> e[i];
  18.         }
  19.        
  20.         bool ok = true;
  21.         for (int i = 1; i < n; ++i)
  22.             if (s[i] >= s[0] && e[i] >= e[0])
  23.                 ok = false;
  24.        
  25.         if (!ok) {
  26.             cout<<"-1"<<endl;
  27.             continue;
  28.         }
  29.        
  30.         cout << s[0] << endl;
  31.     }
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement