提交时间:2021-12-12 22:04:31
运行 ID: 34874
#include <bits/stdc++.h> using namespace std; struct niuma { int north,south; } a[200005]; int n,i,d[200005],len,tmp,f1,f2; bool cmp(niuma x,niuma y) { return x.north<y.north; } int main () { cin>>f1>>f2; cin>>n; for(i=1; i<=n; i++) cin>>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++; } cout<<len; return 0; }