Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define ff first
- #define ss second
- int main()
- {
- _test
- {
- int ans = -1;
- int n;
- cin>>n;
- vector<pair<int, int>> se(n);
- for(auto &[s, e]: se) cin>>s>>e;
- int f = 1;
- int mmax = 0;
- for(int i=1; i<n; i++)
- {
- if(se[i].ff >= se[0].ff)
- mmax = max(mmax, se[i].ss);
- }
- if(se[0].ss > mmax) cout<<se[0].ff<<"\n";
- else cout<<-1<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment