Result: Accepted
Time: 4ms
Memory: 1756kB
#include<iostream>
#include<cmath>
//#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
struct shu{
int x;
int y;
};
int main(){
int n,n1=0,flag=0;
shu a[1001];
shu b[1001];
int s=0,d1,d2;
scanf("%d",&n);
getchar();
scanf("%d %d",&a[0].x,&a[0].y);
b[n1].x=a[0].x;
b[n1].y=a[0].y;
for(int i=1;i<n;++i){
flag=0;
scanf("%d %d",&a[i].x,&a[i].y);
for(int j=0;j<=n1;++j){
if((a[i].x<=b[j].x&&a[i].y<=b[j].y)||(a[i].y<=b[j].x&&a[i].x<=b[j].y)){
flag=1;
b[j].x=a[i].x;
b[j].y=a[i].y;
break;
}
}
if(flag==0){
n1++;
b[n1].x=a[i].x;
b[n1].y=a[i].y;
}
}
printf("%d",n1+1);
return 0;
}