Advertisement
NgJaBach

Compressed Number

Dec 23rd, 2021
941
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.52 KB | None
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long int ll;
  5. //#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
  6. #define pb push_back
  7. #define mp make_pair
  8. #define fi first
  9. #define se second
  10. #define gcd __gcd
  11. #define getl(s) getline(cin, s);
  12. #define setpre(x) fixed << setprecision(x)
  13. #define mset(a) memset(a, 0, sizeof(a))
  14. #define endl '\n'
  15. const int N=500050,M=1000000007;
  16. const ll INF=1e18+7;
  17. int n,x[N],y[N],a[N],maxis=1,L,R,sum=0;
  18. int main(){
  19.     ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
  20. //    freopen(".inp","r",stdin);
  21. //    freopen(".out","w",stdout);
  22.     set<int>ex;
  23.     vector<int>nein;
  24.     mset(a);
  25.     cin>>n;
  26.     for(int i=0;i<n;++i){
  27.         cin>>x[i]>>y[i];
  28.         ex.insert(x[i]);
  29.         ex.insert(y[i]);
  30.     }
  31.     nein.pb(-M);
  32.     for(auto tmp:ex){
  33.         nein.pb(tmp);
  34.     }
  35.     for(int i=0;i<n;++i){
  36.         ++a[lower_bound(nein.begin(),nein.end(),x[i])-nein.begin()];
  37.         --a[lower_bound(nein.begin(),nein.end(),y[i]+1)-nein.begin()];
  38.     }
  39.     for(int i=1;i<=nein.size();++i){
  40.         a[i]+=a[i-1];
  41.         maxis=max(maxis,a[i]);
  42.     }
  43.     cout<<maxis;
  44.     return 0;
  45. }
  46. /*
  47. ==================================+
  48. INPUT:                            |
  49. ------------------------------    |
  50.  
  51. ------------------------------    |
  52. ==================================+
  53. OUTPUT:                           |
  54. ------------------------------    |
  55.  
  56. ------------------------------    |
  57. ==================================+
  58. */
  59.  
Advertisement
RAW Paste Data Copied
Advertisement