# hdu 1024 Max Sum Plus Plus(最大m子段和)

1.

```#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int INF=1<<30;
int a[1000005];
int dp[1000005];
int maxx[1000005];

int main()
{
int m,n;
while(scanf("%d%d",&m,&n)==2)
{
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
dp[i]=0;
maxx[i]=0;
}
dp[0]=0;
maxx[0]=0;
int ans;
for(int i=1;i<=m;i++)
{
ans=-INF;
for(int j=i;j<=n;j++)
{
dp[j]=max(dp[j-1],maxx[j-1])+a[j];
maxx[j-1]=ans;
ans=max(ans,dp[j]);
}
}
printf("%d\n",ans);
}
return 0;
}
```

## HDU 1024 Max Sum Plus Plus --- dp+滚动数组

HDU 1024 题目大意:给定m和n以及n个数,求n个数的m个连续子系列的最大值,要求子序列不想交. 解题思路:<1>动态规划,定义状态dp[i][j]表示序列前j个数的i段子序列的值,其中第i个子序列包括a[j], 则max(dp[m][k]),m<=k<=n 即为所求的结果 <2>初始状态: dp[i][0] = 0, dp[0][j] = 0; <3>状态转移: 决策:a[j]自己成为一个子段,还是接在前面一个子段的后面 方程: a[j]直接接在前面

## HDU 1024 Max Sum Plus Plus【动态规划求最大M子段和详解 】

Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 29942    Accepted Submission(s): 10516 Problem Description Now I think you have got an AC in Ignatius.L's "Max Sum" problem

## HDU 1024 Max Sum Plus Plus(二维数组转化为一维数组)

Problem Description: Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now you are faced with a more difficult problem. Given a consecutive number seq

## hdu 1024 Max Sum Plus Plus (子段和最大问题)

Max Sum Plus Plus Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 17336    Accepted Submission(s): 5701 Problem Description Now I think you have got an AC in Ignatius.L's "Max Sum" problem