MAGCARI

Durian Company

Oct 13th, 2022
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. /*
  2.     Task    : _example
  3.     Author  : Phumipat C. [MAGCARI]
  4.     Language: C++
  5.     Created : 13 October 2022 [21:20]
  6. */
  7. #include<bits/stdc++.h>
  8. using namespace std;
  9. vector<pair<int ,int > > v;
  10. int main(){
  11.     int n,a,b;
  12.     scanf("%d",&n);
  13.     for(int i=1;i<=n;i++){
  14.         scanf("%d %d",&a,&b);
  15.         v.push_back({a,1});
  16.         v.push_back({b,-1});
  17.     }
  18.     sort(v.begin(),v.end());
  19.     int now = 0,ans = 0;
  20.     for(int i=0;i<v.size();i++){
  21.         now+=v[i].second;
  22.         if(i == v.size()-1 || v[i].first != v[i+1].first)
  23.             ans = max(ans,now);
  24.     }
  25.     printf("%d\n",ans);
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment