Start: Jul, 05, 2019 08:40:00
2019年度暑期短学期达标测试
End: Jul, 05, 2019 11:40:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 6ms
Memory: 1756kB
Author: CT12811291281
In contest: 1281

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>
#include<algorithm>

using namespace std;

int main()
{
	int t = 1, s = 1;
	int i, j;
	int n;
	int a[1000][2];
	scanf("%d", &n);
	for(i=0;i<n;i++){
		for(j=0;j<2;j++){
			scanf("%d", &a[i][j]);
		}
	}
	
	int b[1001][2];
	int sign[1001];
	for(i=0;i<=n+1;i++){
		sign[i] = 0;
	}
	b[0][0] = a[0][0];
	b[0][1] = a[0][1];
	
	for(i=0;i<n;i++){
	    for(j=0;j<s;j++){
	    	if(a[i][0]<=b[j][0]&&a[i][1]<=b[j][1]||a[i][0]<=b[j][1]&&a[i][1]<=b[j][0]){
	    		b[j][0] = a[i][0];
	    		b[j][1] = a[i][1];
	    		sign[i] = 1;
	    		break;
			}
		}
		
		if(sign[i]==0){
			t++;
			s++;
			b[j][0] = a[i][0];
			b[j][1] = a[i][1];
		}
	}
	
//	for(i=0;i<s;i++){
//		printf("%d#%d\n", b[i][0], b[i][1]);
//	}

	printf("%d\n", t);
	
	return 0;
}