提交时间:2024-04-02 13:24:50
运行 ID: 141101
#include<bits/stdc++.h> using namespace std; struct adv{ long long x,y; }a[210000]; long long q[210000]; long long adj(adv xx,adv yy) { return xx.x<yy.x; } long long n,m,i,j,k,h,tmp1,tmp2; int main() { cin>>tmp1>>tmp2; cin>>n; for(i=1;i<=n;++i) cin>>a[i].x>>a[i].y; sort(a+1,a+n+1,adj);//将一岸的城市从小到大排序,为做单调子序列先做足准备 h=1; q[h]=a[1].y; for(i=1;i<=n;++i) { if(a[i].y>q[h]) { h++; q[h]=a[i].y; } else if(a[i].y<q[h]) q[lower_bound(q+1,q+h+1,a[i].y)-q]=a[i].y; } cout<<h; return 0; }