| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么是wa,大牛来看看#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator