标签:
题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=1950
#include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include<vector> #include<queue> #include<algorithm> using namespace std; typedef long long LL; const int maxn=500009; const int INF=0x3f3f3f3f; int n; int a[maxn]; int s[maxn]; int main() { int T; scanf("%d", &T); while(T--) { scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%d", &a[i]); s[0]=0; int len=0; for(int i=1; i<=n; i++) { if(a[i]>s[len]) { s[++len]=a[i]; continue; } int t=upper_bound(s, s+len, a[i])-s; s[t]=a[i]; } printf("%d\n", len); } return 0; }
标签:
原文地址:http://www.cnblogs.com/w-y-1/p/5788982.html