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

为什么是wa,大牛来看看

Posted by zzxy at 2011-03-10 19:11:27 on Problem 2533
#include<stdio.h>
#include<memory.h>
#define max 1002
int D[max];
int N;
int G[max],Max=0;
main()
{
    int i,j;
    scanf("%d",&N);

      for (i=1;i<=N;i++)
      scanf("%d",&D[i]); //输入到D【i】数组中
      for (i=0;i<=N;i++)
      G[i]=-1;             //G【i】数组存的是从最左边到i的最大上升子序列

      G[1]=1;
      for (i=2;i<=N;i++)
      {
        for (j=1;j<i;j++)
          if (D[i]>D[j])
            if (G[i]<G[j]+1)//比较G【i】数组,就是比较上升子序列大小
            G[i]=G[j]+1;

        if (G[i]>Max)//记录最大上升子序列
        Max=G[i];
      }
      printf("%d",Max);



}

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