Phoenix030821 @ 2018-02-10 14:38:00
using namespace std; struct lis{ int p1,p2; }a[100001]; bool cmp(lis m,lis n){ return m.p1<n.p1; } int main(){ int n; cin>>n; for(int x=1;x<=n;x++)cin>>a[x].p1; for(int x=1;x<=n;x++)cin>>a[x].p2; sort(a+1,a+n+1,cmp); int g[n+1],maxa=1; memset(g,0,sizeof(g));g[1]=a[1].p2; for(int x=2;x<=n;x++){ if(a[x].p2>g[maxa])maxa++,g[maxa]=a[x].p2; else{ int low=1,high=maxa+1; while(low<high){ int mid=(low+high)/2; if(a[x].p2<g[mid])high=mid; else low=mid+1; } g[low]=a[x].p2; } } cout<<maxa; return 0; }
by Lolierl @ 2018-02-10 14:41:31
这样的代码没人会看。
用md啊