#include<cstdio>
#include<cstring>
int dp[36000];
int d[36000];
int main()
{
int t=1;
while(~scanf("%d",&d[0])&&d[0]!=-1)
{
int len=1;
while(~scanf("%d",&d[len])&&d[len]!=-1)
{
len++;
}
dp[1]=d[0];
int tot=1;
for(int i=1;i<len;i++)
{
if(d[i]<=dp[tot])
{
tot++;
dp[tot]=d[i];
}
else
{
int l=1;
int r=tot;
while(l<r)
{
int m=(l+r)>>1;
if(dp[m]>d[i])
l=m+1;
else
r=m;
}
dp[r]=d[i];
}
}
printf("Test #%d:\n",t++);
printf(" maximum possible interceptions: %d\n\n",tot);
}
}
poj 1887 dp最长下降子序列
最新推荐文章于 2018-07-22 20:43:46 发布