| ||||||||||
| 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 | |||||||||
用dp做怎么就wa呀??#include<stdio.h>
int a[1001],dp[1001];
int main()
{
int n,i,j,max;
scanf("%d",&n);
for(i = 1;i <= n;i++)
scanf("%d",&a[i]);
dp[1] = 1;max = 1;
for(i = 2;i <= n;i++)
{
if(a[i] > a[i-1])
dp[i] = dp[i-1] + 1;
else
{
for(j = i - 1;j >= 1;j--)
{
if(a[i]>a[j])
{
dp[i] = dp[j]+1;
break;
}
}
}
// printf("%d %d\n",i,dp[i]);
if(dp[i]>max)
max = dp[i];
}
printf("%d\n",max);
return 0;
}/*Sample Input
7
1 7 3 5 9 4 8
Sample Output
4
*/
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator