#include<bits/stdc++.h>
using namespace std;
int N=2005;
struct point{
int id,x,y;
point(int _id=0,int _x=0,int _y=0){
id=_id,x=_x,y=_y;
}
friend bool operator<(point a,point b){
return a.x>b.x;
}
};
int val[200005];
/*vector<int>lis[200005];
void push(int i,int val){
int x=lower_bound(lis[i].begin(),lis[i].end(),val)-lis[i].begin();
if(x==lis[i].size())lis[i].push_back(val);
else lis[i][x]=val;
}*/
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;cin>>n;
vector<point>p;
for(int i=0;i<n;i++){
int a,b;cin>>a>>b;
p.push_back(point(i,a+1,b+1));
}
sort(p.begin(),p.end());
int ans=0;
for(int i=0;i<p.size();i++){
for(int j=0;j<i;j++){
if(p[i].y>p[j].y)continue;
if(p[i].y>val[p[j].id])val[p[j].id]=p[i].y,ans++;
}
}
//for(int i=0;i<p.size();i++)ans+=lis[i].size();
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |