#include<cstdio>
#include<algorithm>
#define maxn 1001
using namespace std;
int stack[maxn],N;
int main()
{
scanf("%d",&N);
int top=0;
stack[0]=-1;
for(int i=0;i<N;i++)
{
int temp;
scanf("%d",&temp);
if(stack[top]<temp)
{
stack[++top]=temp;
}
else
{
int low=1,high=top;
int mid;
while(low<=high)
{
mid=(low+high)/2;
if(stack[mid] < temp)
{
low=mid+1;
}
else
{
high=mid-1;
}
}
stack[low]=temp;
}
}
printf("%d\n",top);
return 0;
}
POJ 2533 求最长上升子序列长度 非DP 实现
最新推荐文章于 2021-12-11 17:34:48 发布