#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <stack>
#include <set>
#include <map>
#include <vector> using namespace std;
#define INF 0x7fffffff
#define LL long long
#define MAX(a,b) ((a)>(b))? (a):(b)
struct node{
int x,y,w;
};
int a[1000005];
LL dp[1000005];//dp[i] 为前i个里面的是包含a[i]的m个子端的最大值这里面用了滚动数组,
LL cc[1000005];//前i个分成m个子端的最大和的位置
int main(){
int n,m;
while(cin >> m >> n){
for(int i = 1;i <= n;i++){
scanf("%d",&a[i]);
dp[i] = 0;
cc[i] = 0; }
dp[0] = 0;
cc[0] = 0;
LL mmax;
for(int i = 1;i <= m;i++){
mmax = -INF;
for(int j = i;j <= n;j++){
dp[j] = MAX(dp[j-1]+a[j],cc[j-1]+a[j]);
cc[j-1] = mmax;
mmax = MAX(mmax,dp[j]);
}
} printf("%I64d\n",mmax);
}
return 0;
}

最新文章

  1. HTML学习笔记--HTML的语法【1】
  2. 【转】TextView长按复制实现方法小结
  3. 最近点对问题 POJ 3714 Raid &amp;&amp; HDOJ 1007 Quoit Design
  4. 百度地图API示例之设置地图显示范围
  5. JSP表单处理
  6. HDU 4497 数论+组合数学
  7. Codeforces Gym 100002 B Bricks 枚举角度
  8. 实现微信文章页面 http://mp.weixin.qq.com/s?__biz=MjM5MDI3OTAwMg==&amp;amp;mid=200337417&amp;amp;idx=1&amp;amp;sn=5959ed1d722c7da66b
  9. UIButton 按钮文字左对齐
  10. iOS 返回到指定的ViewController
  11. C++ Code_combobox
  12. js生成验证码并且判断
  13. 微信面试题-获取元素的最终background-color
  14. 浅谈卷积神经网络及matlab实现
  15. 《并行程序设计导论》——MPI(Microsoft MPI)(1):Hello
  16. Android项目的targetSDK&gt;=23,在低于Android6.0的部分测试机(类似华为)上运行时出现的系统权限问题
  17. in和hasOwnProperty的区别
  18. git 配置ssh key
  19. java 之2D过气游戏类的写法
  20. SQL注入之Sqli-labs系列第十八关(基于错误的用户代理,头部POST注入)

热门文章

  1. mysql 笔记(一)
  2. ref:如何在大量jar包中搜索特定字符
  3. linux网络管理----网络基础
  4. SCU 4445 Right turn
  5. disconf-web 分布式配置管理平台
  6. GeneXus手机开发基础配置
  7. Git in Powershell saying 'Could not find ssh-agent'
  8. wampserver -- 解决Exception Exception in module wampmanager.exe at 000F15A0
  9. python开发_tkinter
  10. 机器学习中的 precision、recall、accuracy、F1 Score