using namespace std;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;
vector<pair<int,int> > aka,ao;
bool past[101];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout<<fixed;
#ifdef LOCAL_DEFINE
FILE *stream1;
stream1=freopen("in","r",stdin);
if(stream1==NULL)return 0;
#endif
cin>>n;
for(int i=0;i<n;i++){
int a,b;cin>>a>>b;
aka.push_back({a,b});
}
for(int i=0;i<n;i++){
int a,b;cin>>a>>b;
ao.push_back({a,b});
}
sort(ao.begin(),ao.end());
int ans=0;
for(int i=0;i<n;i++){
int maxy=-1;
int res=-1;
for(int j=0;j<n;j++){
if(past[j])continue;
if(aka[j].fi<ao[i].fi && aka[j].se<ao[i].se){
if(maxy<aka[j].se){
res=j;
maxy=aka[j].se;
}
}
}
if(res!=-1){
past[res]=1;
ans++;
}
}
print(ans);
#ifdef LOCAL_DEFINE
cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
fclose(stream1);
#endif
return 0;
}
- 赤の点は左下にあるほど貴重なので、青の点と友達にするのは取れる赤の点のうち最も下にあるもの。
- これを最初に青のx座標でソートして行えば大丈夫。
- x座標でソートしたら、もう赤のx座標のことは考えなくていいよね。