hdu 1087 Super Jumping! Jumping! Jumping!
2013-11-15 10:18
316 查看
就是求和最大的上升子序列(可以间断)。
#include <iostream>
#include<stdio.h>
#include<cstring>
using namespace std;
int a[1005],d[1005];
int main()
{
int n,i,j,max,m;
while(scanf("%d",&n),n)
{int max=-1100;
m=0;
memset(d,0,sizeof(d));
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
d[0]=a[0];
m=0;
for(j=0;j<i;j++)
{
if(d[j]>=m&&a[j]<a[i])
m=d[j];
}
d[i]=m+a[i];
if(d[i]>max)
max=d[i];
}
printf("%d\n",max);
}
return 0;
}
#include <iostream>
#include<stdio.h>
#include<cstring>
using namespace std;
int a[1005],d[1005];
int main()
{
int n,i,j,max,m;
while(scanf("%d",&n),n)
{int max=-1100;
m=0;
memset(d,0,sizeof(d));
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
d[0]=a[0];
m=0;
for(j=0;j<i;j++)
{
if(d[j]>=m&&a[j]<a[i])
m=d[j];
}
d[i]=m+a[i];
if(d[i]>max)
max=d[i];
}
printf("%d\n",max);
}
return 0;
}
相关文章推荐
- hdu 1087 Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping! (LIS)
- hdu 1087 Super Jumping! Jumping! Jumping!
- hdu 1087 Super Jumping! Jumping! Jumping!(简单dp)
- hdu 1087 Super Jumping! Jumping! Jumping! ----dp
- hdu - 1087 - Super Jumping! Jumping! Jumping!
- HDU-1087(Super Jumping! Jumping! Jumping!)(LCS)
- HDU 1087 Super Jumping! Jumping! Jumping!(最大的上升子序列的和)(不是最长)(易混淆)
- hdu 1087 Super Jumping! Jumping! Jumping!(dp:上升子序列最大和)
- HDU-1087 Super Jumping! Jumping! Jumping! (线性dp 上升子序列最大和)
- HDU_1087_Super Jumping! Jumping! Jumping!_dp
- HDU 1087 Super Jumping! Jumping! Jumping!
- 动态规划HDU-1087 Super Jumping! Jumping! Jumping!
- [HDU - 1087]Super Jumping! Jumping! Jumping!(动态规划)
- HDU 1087 Super Jumping! Jumping! Jumping!
- HDU 1087 Super Jumping! Jumping! Jumping!
- HDU-1087 Super Jumping! Jumping! Jumping!( DP )
- Super Jumping! Jumping! Jumping! HDU - 1087
- hdu 1087 Super Jumping! Jumping! Jumping!(动态规划DP)
- E - Super Jumping! Jumping! Jumping! HDU 1087 (基础动态规划)