Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~
The new ITone 6 has been released recently and George got really keen to buy it. Unfortunately, he didn't have enough money, so George was going to work as a programmer. Now he faced the following problem at the work.
Given a sequence of n integers p1, p2, ..., pn. You are to choose k pairs of integers:
[l1, r1], [l2, r2], ..., [lk, rk] (1 ≤ l1 ≤ r1 < l2 ≤ r2 < ... < lk ≤ rk ≤ n; ri - li + 1 = m),
in such a way that the value of sum is maximal possible. Help George to cope with the task.
The first line contains three integers n, m and k (1 ≤ (m × k) ≤ n ≤ 5000). The second line contains n integersp1, p2, ..., pn (0 ≤ pi ≤ 109).
Print an integer in a single line — the maximum possible value of sum.
5 2 1
1 2 3 4 5
9
7 1 3
2 10 7 18 5 33 0
61
#include <iostream>
#include <cstdio>
#define LL long long
using namespace std;
const int maxn = + ;
LL p[maxn],s[maxn],dp[maxn][maxn];
int main(){
int n,m,k;
cin>>n>>m>>k;
for(int i = ;i <= n;i++){
cin>>p[i];s[i] = s[i - ] + p[i];
}
for(int i = m;i <= n;i++)
for(int j = ;j <= k;j++)
dp[i][j] = max(dp[i-m][j-]+s[i]-s[i-m],dp[i-][j]);
cout<<dp[n][k]<<endl;
return ;
}
Codeforces Round #267 (Div. 2) C. George and Job(DP)补题的更多相关文章
-
Codeforces Round #267 (Div. 2) C. George and Job DP
C. George and Job The new ITone 6 has been released ...
-
01背包 Codeforces Round #267 (Div. 2) C. George and Job
题目传送门 /* 题意:选择k个m长的区间,使得总和最大 01背包:dp[i][j] 表示在i的位置选或不选[i-m+1, i]这个区间,当它是第j个区间. 01背包思想,状态转移方程:dp[i][j ...
-
Codeforces Round #267 (Div. 2) C. George and Job (dp)
wa哭了,,t哭了,,还是看了题解... 8170436 2014-10-11 06:41:51 njczy2010 C - George and Jo ...
-
Codeforces Round #367 (Div. 2) C. Hard problem(DP)
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...
-
Codeforces Round #368 (Div. 2) A. Brain&#39;s Photos (水题)
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...
-
Codeforces Round #227 (Div. 2) E. George and Cards set内二分+树状数组
E. George and Cards George is a cat, so he loves playing very much. Vitaly put n cards in a row in ...
-
Codeforces Round #227 (Div. 2) E. George and Cards 线段树+set
题目链接: 题目 E. George and Cards time limit per test:2 seconds memory limit per test:256 megabytes 问题描述 ...
-
Codeforces Round #267 (Div. 2) A
题目: A. George and Accommodation time limit per test 1 second memory limit per test 256 megabytes inp ...
-
Codeforces Round #267 (Div. 2) B. Fedor and New Game【位运算/给你m+1个数让你判断所给数的二进制形式与第m+1个数不相同的位数是不是小于等于k,是的话就累计起来】
After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play ...
随机推荐
-
vc++ 加载,卸载自己的驱动程序
用vc++加载自己的驱动程序主要分为以下几个步骤: 1.加载驱动服务 主要要用到以下几个函数 SC_HANDLE WINAPI OpenSCManagerA( __in_opt LPCS ...
-
在ALV中更新数据库表
FORM usercommand USING ucomm TYPE sy-ucomm selfield TYPE slis_selfield. DATA: lr_grid TYPE REF TO cl ...
-
java中在linux下利用jstack检测死锁
首先,编写一个死锁程序 package deadlock; public class testJstack { final static Object resource_1 = new Object( ...
-
【转】Android studio 导入github工程
http://blog.csdn.net/feixiaku/article/details/45155587/ 从github下载两个开源项目: PagerSlidingTabStrip | ...
-
jenkins 每个月1号到7号 一天执行一次
在线Crontab表达式执行时间验证 / crontab执行时间计算 - aTool在线工具验证 http://www.atool.org/crontab.php 1.Build periodic a ...
-
php处理ajax请求,ajax+php实现跨域
第一种方法通过设置Access-Control-Allow-Origin来实现跨域 1.首先要了解什么是域? 什么是域,简单来说就是协议+域名或地址+端口,3者只要有任何一个不同就表示不在同一个域.跨 ...
-
English trip EM2-LP-4B At School Teacher:Russell
课上内容(Lesson) Where is Loki a student? Loki is in Meten, BaobaoStreet, Chengdu. What is he studying? ...
-
CodeForces Contest #1137: Round #545 (Div. 1)
比赛传送门:CF #1137. 比赛记录:点我. 每次都自闭的 div1 啊,什么时候才能上 IM 呢. [A]Skyscrapers 题意简述: 有一个 \(n\times m\) 的矩阵 \(a_ ...
-
如何实现php手机短信验证功能
http://www.qdexun.cn/jsp/news/shownews.do?method=GetqtnewsdetailAction&id=1677 下载php源代码 现在网站在建设网 ...
-
解决UITableView在iOS7中UINavigationController里的顶部留白问题
解决UITableView在iOS7中UINavigationController里的顶部留白问题 出现问题时候的截图: 源码: 用到的类: UIViewController+TitleTextAtt ...