提交时间:2021-12-13 13:32:12

运行 ID: 35075

#include<stdio.h> #include<algorithm> using namespace std; struct node { int north,south; } a[200005]; int n,i,d[200005],len,temp,f1,f2; bool cmp(node x,node y) { return x.north<y.north; } int main () { scanf("%d%d",&f1,&f2); scanf("%d",&n); for(i=1; i<=n; i++) scanf("%d%d",&a[i].north,&a[i].south); sort(a+1,a+1+n,cmp); d[++len]=a[1].south; for(i=2; i<=n; i++) { int ll=upper_bound(d+1,d+len+1,a[i].south)-d; d[ll]=a[i].south; if(ll>len) len++; } printf("%d",len); return 0; }