类似LIS,只不过判断是从大到小,你妹,括号放错位置了,白白wa了3次。。。
#include <stdio.h>
int s[10000006];
int main()
{
int i,j,n,temp,top,num;
num=0;
while((scanf("%d",&n)==1)&&(n!=-1))
{
num++;
top=1;
s[top]=n;
while((scanf("%d",&temp)==1)&&(temp!=-1))
{
if (temp<=s[top])
s[++top]=temp;
else
{
int low=1;
int high=top;
while(low<=high)
{
int middle=(low+high)/2;
if (s[middle]<temp)
{
high=middle-1;
}
else
{
low=middle+1;
}
}
s[low]=temp;
}
}
if (num>=2)
printf("\nTest #%d:\n maximum possible interceptions: %d\n",num,top);
else
printf("Test #%d:\n maximum possible interceptions: %d\n",num,top);
}
return 0;
}