标签:
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn = 1E6 + 10;
int a[maxn];
int dp[maxn],premax[maxn];
int main(){
int n,m;
while(~scanf("%d%d",&m,&n)){
int i;
for(i = 1;i <= n ; ++i){
scanf("%d",&a[i]);
}
memset(dp,0,sizeof(dp));
memset(premax,0,sizeof(premax));
int tmpmax;
for(int ii = 1;ii <= m ; ++ii){
tmpmax = 0x8f8f8f8f;
for(int j = ii; j <= n;++j){
dp[j] = max(dp[j - 1] + a[j],premax[j - 1] + a[j]);
premax[j - 1] = tmpmax;
tmpmax = max(dp[j],tmpmax);
}
}
printf("%d\n",tmpmax);
}
return 0;
}
[2016-03-28][HDU][1024][Max Sum Plus Plus]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/52d5b029e63b731ab9ce15d62f9090b9.html