标签:
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
const int maxn = 1E4 * 5 + 10;
int a[maxn],stk[maxn];
int main(){
int n;
scanf("%d",&n);
for(int i = 1 ; i <= n ; ++i){
scanf("%d",&a[i]);
}
int pcur = 0;
for(int i = 1;i <= n;++i){
if(!pcur){
stk[pcur++] = a[i];
}else {
if(a[i] > stk[pcur - 1]){
stk[pcur++] = a[i];
}else if(a[i] < stk[pcur - 1]){
int pos = lower_bound(stk,stk + pcur,a[i]) - stk;
stk[pos] = a[i];
}
}
}
printf("%d\n",pcur);
return 0;
}
[2016-05-11][51nod][1134 最长递增子序列]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/6f10926a60110ebae3d3ccbf0354e2f5.html