Result: Accepted
Time: 5ms
Memory: 1756kB
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<math.h>
#include<map>
using namespace std;
const int maxn=100020;
const int inf=0x3f3f3f;
int main(){
int t;
cin>>t;
int x,y;
int cnt=1;
int a[2000],b[2000];
memset(a,0,sizeof a);
memset(b,0,sizeof b);
cin>>x>>y;
a[1]=x;
b[1]=y;
t--;
while(t--){
cin>>x>>y;
int flag=0;
for(int i=1;i<=cnt;i++){
if(x<=a[i]&&y<=b[i]||x<=b[i]&&y<=a[i]){
a[i]=x;
b[i]=y;
flag=1;
break;
}
}
if(flag==0){
++cnt;
a[cnt]=x;
b[cnt]=y;
}
}
cout<<cnt<<endl;
}