Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- #include<iomanip>
- #include<algorithm>
- #include<cstdlib>
- #include<cstring>
- #include<vector>
- #include<utility>
- #define ll long long
- #define sz(x) int(x.size())
- #define all(x) x.begin(),x.end()
- using namespace std;
- void Fast_IO(){
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- #endif
- }
- bool compare(pair<ll,ll>& a,pair<ll,ll>& b){
- if(a.first==b.first)
- return a.second>b.second;
- return a.first<b.first;
- }
- bool comp(pair<ll,ll>& a,pair<ll,ll>& b){
- if(a.second==b.second) return a.first<b.first;
- return a.second>b.second;
- }
- void solve(){
- ll n; cin>>n;
- pair<ll,ll>p[n];
- for(int i =0; i<n; i++){
- cin>>p[i].first>>p[i].second;
- }
- sort(p,p+n,compare);
- sort(p+1,p+n,comp);
- if(p[0].first<=p[1].first && p[0].second>=p[1].second){
- cout<<1;
- }else if(p[1].first <= p[0].second){
- cout<<"2";
- }else{
- ll counter =0;
- for(int i =2; i<n;i++){
- if(p[i].second<=p[0].second || p[i].first>= p[1].first) counter++;
- }
- cout<<n-counter;
- }
- // for(int i=0; i<n; i++){
- // cout<<p[i].first<<' '<<p[i].second<<endl;
- // }
- }
- int main(){
- Fast_IO();
- int t =1;
- //cin>>t;
- while(t--){
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement