这是我代码,你看看
#include
using namespace std;
int ac[500001];
int n;
int temp[500001];
int dp()
{
int i,low,high,mid,len=0;
for(i=1;i<=n;i++)
{
low=1;
high=len;
while(low<=high)
{
mid=(low+high)/2;
if(temp[mid]>=ac[i])
high=mid-1;
else
low=mid+1;
}
temp[low]=ac[i];
if(low>len)len++;
}
return len;
}
int main()
{
int i,a,b,t,len;
t=0;
while(scanf("%d",&n)!=EOF)
{
t++;
for(i=0;i
scanf("%d%d",&a,&b);
ac[a]=b;
}
len=dp();
printf("Case %d:\nMy king, at most %d road",t,len);
if(len!=1) printf("s");
printf(" can be built.\n\n");
}
}