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: 4ms
Memory: 1772kB
Author: CT12810831281
In contest: 1281

#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;
}