Codeforces 467C. George and Job (dp)
题目链接:http://codeforces.com/contest/467/problem/C
求k个不重叠长m的连续子序列的最大和。
dp[i][j]表示第i个数的位置个序列的最大和。
前缀和一下就好了。空间可以优化,滚动数组就好了。
//#pragma comment(linker, "/STACK:102400000, 102400000")
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
typedef pair <int, int> P;
const int N = 5e3 + ;
LL dp[N][];
LL sum[N]; int main()
{
int n, m, k;
scanf("%d %d %d", &n, &m, &k);
for(int i = ; i <= n; ++i) {
scanf("%lld", sum + i);
sum[i] += sum[i - ];
}
for(int j = ; j <= k; ++j) {
for(int i = m*j; i <= n; ++i) {
dp[i][j%] = max(dp[i - m][(j - )%] + sum[i] - sum[i - m], dp[i - ][j%]);
}
}
printf("%lld\n", dp[n][k%]);
return ;
}
Codeforces 467C. George and Job (dp)的更多相关文章
- 【题解】codeforces 467C George and Job dp
题目描述 新款手机 iTone6 近期上市,George 很想买一只.不幸地,George 没有足够的钱,所以 George 打算当一名程序猿去打工.现在George遇到了一个问题. 给出一组有 n ...
- Codeforces 467C George and Job(DP)
题目 Source http://codeforces.com/contest/467/problem/C Description The new ITone 6 has been released ...
- codeforces 467C George and Job(简单dp,看了题解抄一遍)
题目 参考了网页:http://www.xue163.com/exploit/180/1802901.html //看了题解,抄了一遍,眼熟一下,增加一点熟练度 //dp[i][j]表示是前i个数选出 ...
- codeforces 467C.George and Job 解题报告
题目链接:http://codeforces.com/problemset/problem/467/C 题目意思:给出一条含有 n 个数的序列,需要从中找出 k 对,每对长度为 m 的子序列,使得 找 ...
- Codeforces 467C. George and Job
DP.... C. George and Job time limit per test 1 second memory limit per test 256 megabytes input stan ...
- [BZOJ 3625] [Codeforces 438E] 小朋友的二叉树 (DP+生成函数+多项式开根+多项式求逆)
[BZOJ 3625] [Codeforces 438E] 小朋友的二叉树 (DP+生成函数+多项式开根+多项式求逆) 题面 一棵二叉树的所有点的点权都是给定的集合中的一个数. 让你求出1到m中所有权 ...
- Codeforces Round #267 (Div. 2) C. George and Job DP
C. George and Job The new ITone 6 has been released ...
- Codeforces Round #267 Div2 C George and Job --DP
题意:把长度为n的序列分成k个m长的连续小序列,这些连续小序列的和最大是多少. 解法:显然DP. 定义: dp[i][j] 为前 i 个元素分成j个m端,且 i 是第j个的末尾的最大和. 那么有: d ...
- 【Codeforces 467C】George and Job
[链接] 我是链接,点我呀:) [题意] 让你从1..n这n个数字中 选出来k个不相交的长度为m的区间 然后这个k个区间的和最大 求出这k个区间的和的最大值 [题解] 设dp[i][j]表示前i个数字 ...
随机推荐
- UVa 11090 Going in Cycle!!【Bellman_Ford】
题意:给出n个点m条边的加权有向图,求平均值最小的回路 自己想的是用DFS找环(真是too young),在比较找到各个环的平均权值,可是代码实现不了,觉得又不太对 后来看书= =好巧妙的办法, 使用 ...
- BZOJ 1787 紧急集合
LCA.注意细节. #include<iostream> #include<cstdio> #include<cstring> #include<algori ...
- Sqlserver高级查询
1.查询表结构 --查询表结构(字段名.字段类型.字段长度.能否为空) SELECT syscolumns.name,systypes.name, syscolumns.length ,syscolu ...
- 【英语】Bingo口语笔记(20) - i长短音
短音有个ei的音,多练习下 长音是咦拉长
- 【英语】Bingo口语笔记(24) - L的发音技巧
舌头往上跑
- xxx
<div style="position:absolute;left:0px;top:50px;width:1300px;height:550px;"><d ...
- windows xp 安装mysql5.6.17-ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password
.zip解压后没有setup 没有my.ini 1.安装方法 bin目录下执行以下: E:\mysql-5.6.17-win32\bin>mysqld install MySQL --defau ...
- blender2.7.4安装three.js插件
将three.js-master\utils\exporters\blender\addons 下面的io_three文件夹,拷贝到blender安装目录:blender-2.74-windows64 ...
- CleanMyMac2清理 lanchpad里面的图标没了
好吧.用CleanMyMac2 清理了系统(10.9)之后图标没了.解决办法是: Launchpad存储在一个SQLite数据库中,存储目录是: ~/Library/Application Suppo ...
- @Component @Repository @Service @Controller
Spring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository.@Service 和 @Controller.在目前的 Spring ...