Result: Accepted
Time: 4ms
Memory: 1772kB
#include<iostream>
#include<string>
#include<cmath>
struct o {
int chang;
int kuan;
} a[1001],b[1001];
using namespace std;
int main() {
int n,sum,k,g;
cin>>n;
for(int i=0; i<n; ++i) {
cin>>a[i].chang>>a[i].kuan;
}
b[0].chang=a[0].chang;
b[0].kuan=a[0].kuan;
sum=1;
for(k=1; k<n; ++k) {
for(g=0; g<sum; ++g) {
if((a[k].chang<=b[g].chang&&a[k].kuan<=b[g].kuan)||(a[k].kuan<=b[g].chang&&a[k].chang<=b[g].kuan)) {
b[g].chang=a[k].chang;
b[g].kuan=a[k].kuan;
break;
}
}
if(g==sum){
b[sum].chang=a[k].chang;
b[sum].kuan=a[k].kuan;
sum++;
}
}
cout<<sum<<endl;
return 0;
}