提交时间:2024-03-30 15:04:24
运行 ID: 140402
#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);//对北边排序(万能的sort) //下面是STL二分的模板 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;//完美结束 }//yhcs