Ankit_132

A

Sep 24th, 2023
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  7. #define ff     first
  8. #define ss     second
  9.  
  10. int main()
  11. {
  12.     _test
  13.     {
  14.         int ans = -1;
  15.  
  16.         int n;
  17.         cin>>n;
  18.  
  19.         vector<pair<int, int>> se(n);
  20.         for(auto &[s, e]: se)       cin>>s>>e;
  21.  
  22.         int f = 1;
  23.         int mmax = 0;
  24.  
  25.         for(int i=1; i<n; i++)
  26.         {
  27.             if(se[i].ff >= se[0].ff)
  28.                 mmax = max(mmax, se[i].ss);
  29.         }
  30.  
  31.         if(se[0].ss > mmax)     cout<<se[0].ff<<"\n";
  32.         else                    cout<<-1<<"\n";
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment