Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

无奈,苦恼

Posted by 1030202872 at 2010-07-29 21:24:45 on Problem 1887
这道题,感觉可能错误的地方都想到了,为什么还会WA呢?
#include <stdio.h>
void main()
{
 int count,num[10000],dp[10000],max,n,i,j,judge=0,cal=0;
 while(judge!=-1)
 {
  i=1;
  count=0;
  cal++;
  scanf("%d",&n);
  while(n!=-1)
  {
   num[i]=n;
   i++;
   judge=1;
   count++;
   scanf("%d",&n);
  }
  if(n==-1) judge-=1;
  dp[1]=1;
  for(i=2;i<=count;i++)
  {
	max=1;
    j=1;
	while(j<=i-1)
	{
     if(num[i]<=num[j])
      if(dp[j]+1>max)
       max=dp[j]+1;
	  j++;
	}
		dp[i]=max;
  }
  if(judge!=-1)
  {
   printf("Test #%d:\n",cal);
   printf("  maximum possible interceptions: %d\n\n",dp[count]);
  }
 }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator