For the use of Lower_bound () See: http://blog.csdn.net/niushuai666/article/details/6734403***
#include <iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#include<cctype>#include<queue>#include<vector>#include<algorithm>using namespaceStd;typedefLong LongLL;#defineN 101000#defineINF 0x3f3f3fintA[n], g[n], d[n];intMain () {intT, N, cas=1; scanf ("%d", &u); while(t--) {scanf ("%d", &N); for(intI=1; i<=n; i++) {G[i]=INF; scanf ("%d", &A[i]); } intnum, ans; Num=ans=0; for(intI=1; i<=n; i++) { if(a[i]==0) {num++; Continue; } A[i]-=num;//minus the number of front zeros, so you can tick some numbers and leave enough space for the zero transformation .intK=lower_bound (g+1, g+n+1, A[i])-G; D[i]=K; G[K]=A[i]; Ans=Max (ans, d[i]); } printf ("Case #%d:%d\n", cas++, ans+num); } return 0;}
HUD 5773 LIS (longest ascent sequence)