Codeforces Round #267 (Div. 2) C. George and Job(DP)补题
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'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 ...
随机推荐
- Linux环境搭建SVN服务
一.准备工作 首先要保证自己的linux电脑能上外网,我这电脑因为是新的,没有配置网络,所以再这块花费了点时间. 1.检查ip信息 >ifconfig 2.检查DNS服务器 >cat / ...
- Yii 2.0版本调试输出SQL语句
项目是基于框架Yii 2.0开发的. 今天梳理一些数据统计功能代码的时候,想把当前运行的sql语句打印出来,然后放到navicat工具里面运行,并分析一下运行效率和调优方案,之前大部分时候都是写增加. ...
- [Python3网络爬虫开发实战] 1.7.1-Charles的安装
Charles是一个网络抓包工具,相比Fiddler,其功能更为强大,而且跨平台支持得更好,所以这里选用它来作为主要的移动端抓包工具. 1. 相关链接 官方网站:https://www.charles ...
- 78-DeMarker,价格波动指数.(2015.7.1)
DeMarker 价格波动指数 观井映天 2015.7.1
- Web的三大基石
[HTML] 实现了Web页面. [URL] 1.url Uniform Resource Locator的缩写,称为统一资源定位符.通过URL可以访问到互联网上的一个资源.如:图片.视频.网页等.通 ...
- Lucene_Hello(示例)
(1)创建project (2)导入Lucene的核心包 (3)编写代码建立索引 /lucene01/src/cn/hk/lucene/TestIndex.java: package cn.hk.lu ...
- 编程数学(A-1)-(B-1)-一个数的负次方怎么算
一个数的负几次方就是这个数的几次方的倒数.当这个数是正整数时,也就是说一个数的负n次方就是这个数的n次方分之一.例如: 2的-2次方=2的2次方分之1=4分之13的-2次方=3的2次方分之1=9分之1 ...
- python用模块zlib压缩与解压字符串和文件的方法
摘自:http://www.jb51.net/article/100218.htm Python标准模块中,有多个模块用于数据的压缩与解压缩,如zipfile,gzip, bz2等等. python中 ...
- bzoj 1962 硬币游戏 (猜数问题)
[bzoj1962]模型王子 2015年3月26日1,6460 Description Input 输入数据共一行,两个整数N,K,用一个空格隔开,具体意义如题目中所述. Output 输出数据共一行 ...
- 【BZOJ3697】采药人的路径(点分治)
题意:采药人的药田是一个树状结构,每条路径上都种植着同种药材.采药人以自己对药材独到的见解,对每种药材进行了分类.大致分为两类,一种是阴性的,一种是阳性的.采药人每天都要进行采药活动.他选择的路径是很 ...