Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- //#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
- #define pb push_back
- #define mp make_pair
- #define fi first
- #define se second
- #define gcd __gcd
- #define getl(s) getline(cin, s);
- #define setpre(x) fixed << setprecision(x)
- #define mset(a) memset(a, 0, sizeof(a))
- #define endl '\n'
- const int N=500050,M=1000000007;
- const ll INF=1e18+7;
- int n,x[N],y[N],a[N],maxis=1,L,R,sum=0;
- int main(){
- ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
- // freopen(".inp","r",stdin);
- // freopen(".out","w",stdout);
- set<int>ex;
- vector<int>nein;
- mset(a);
- cin>>n;
- for(int i=0;i<n;++i){
- cin>>x[i]>>y[i];
- ex.insert(x[i]);
- ex.insert(y[i]);
- }
- nein.pb(-M);
- for(auto tmp:ex){
- nein.pb(tmp);
- }
- for(int i=0;i<n;++i){
- ++a[lower_bound(nein.begin(),nein.end(),x[i])-nein.begin()];
- --a[lower_bound(nein.begin(),nein.end(),y[i]+1)-nein.begin()];
- }
- for(int i=1;i<=nein.size();++i){
- a[i]+=a[i-1];
- maxis=max(maxis,a[i]);
- }
- cout<<maxis;
- return 0;
- }
- /*
- ==================================+
- INPUT: |
- ------------------------------ |
- ------------------------------ |
- ==================================+
- OUTPUT: |
- ------------------------------ |
- ------------------------------ |
- ==================================+
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement