| ||||||||||
| 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 | |||||||||
逻辑有问题,如果前面没有数比它小,长度应该为1 ,看我ac的In Reply To:How could this be wrong? 555 Posted by:yogafrank at 2007-11-30 20:08:01 #include "stdio.h"
int main(void)
{
int n,a[1001],c[1001];
int i,j,temp,max;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
c[1]=1;
for(i=2;i<=n;i++)
{
max=1;
for(j=i-1;j>=1;j--)
{
if (max>j+1) {
break;
}
if (a[i]>a[j]) {
temp=c[j]+1;
if (temp>max) {max=temp;
}
}
}
c[i]=max;
}
max=1;
for(i=1;i<=n;i++)
{
if (c[i]>max) {max=c[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