原题:http://poj.org/problem?id=3903
题意:求最长上升子序列的个数;
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1000000+10;
int stack[maxn];
int n;
int main()
{
while(~scanf("%d", &n))
{
int top = 0;
stack[top] = -1;
for(int i = 1;i<=n;i++)
{
int tmp;
scanf("%d", &tmp);
if(tmp > stack[top])
stack[++top] = tmp;
else
{
int pos = lower_bound(stack+1, stack+top+1, tmp) - stack;
stack[pos] = tmp;
}
}
printf("%d\n", top);
}
return 0;
}