Codeforces Round #267 (Div. 2) C. George and Job(DP)补题

时间:2022-03-19 18:01:25

                        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 ≤ nri - li + 1 = m), 

in such a way that the value of sum Codeforces Round #267 (Div. 2) C. George and Job(DP)补题 is maximal possible. Help George to cope with the task.

Input

The first line contains three integers nm and k (1 ≤ (m × k) ≤ n ≤ 5000). The second line contains n integersp1, p2, ..., pn (0 ≤ pi ≤ 109).

Output

Print an integer in a single line — the maximum possible value of sum.

Sample test(s)
Input
5 2 1
1 2 3 4 5
Output
9
Input
7 1 3
2 10 7 18 5 33 0
Output
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)补题的更多相关文章

  1. Codeforces Round &num;267 &lpar;Div&period; 2&rpar; C&period; George and Job DP

                                                  C. George and Job   The new ITone 6 has been released ...

  2. 01背包 Codeforces Round &num;267 &lpar;Div&period; 2&rpar; C&period; George and Job

    题目传送门 /* 题意:选择k个m长的区间,使得总和最大 01背包:dp[i][j] 表示在i的位置选或不选[i-m+1, i]这个区间,当它是第j个区间. 01背包思想,状态转移方程:dp[i][j ...

  3. Codeforces Round &num;267 &lpar;Div&period; 2&rpar; C&period; George and Job (dp)

    wa哭了,,t哭了,,还是看了题解... 8170436                 2014-10-11 06:41:51     njczy2010     C - George and Jo ...

  4. Codeforces Round &num;367 &lpar;Div&period; 2&rpar; C&period; Hard problem(DP)

    Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...

  5. Codeforces Round &num;368 &lpar;Div&period; 2&rpar; A&period; Brain&&num;39&semi;s Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  6. Codeforces Round &num;227 &lpar;Div&period; 2&rpar; E&period; George and Cards set内二分&plus;树状数组

    E. George and Cards   George is a cat, so he loves playing very much. Vitaly put n cards in a row in ...

  7. Codeforces Round &num;227 &lpar;Div&period; 2&rpar; E&period; George and Cards 线段树&plus;set

    题目链接: 题目 E. George and Cards time limit per test:2 seconds memory limit per test:256 megabytes 问题描述 ...

  8. Codeforces Round &num;267 &lpar;Div&period; 2&rpar; A

    题目: A. George and Accommodation time limit per test 1 second memory limit per test 256 megabytes inp ...

  9. Codeforces Round &num;267 &lpar;Div&period; 2&rpar; B&period; Fedor and New Game【位运算&sol;给你m&plus;1个数让你判断所给数的二进制形式与第m&plus;1个数不相同的位数是不是小于等于k,是的话就累计起来】

    After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play ...

随机推荐

  1. vc&plus;&plus; 加载&comma;卸载自己的驱动程序

    用vc++加载自己的驱动程序主要分为以下几个步骤: 1.加载驱动服务 主要要用到以下几个函数 SC_HANDLE WINAPI OpenSCManagerA( __in_opt        LPCS ...

  2. 在ALV中更新数据库表

    FORM usercommand USING ucomm TYPE sy-ucomm selfield TYPE slis_selfield. DATA: lr_grid TYPE REF TO cl ...

  3. java中在linux下利用jstack检测死锁

    首先,编写一个死锁程序 package deadlock; public class testJstack { final static Object resource_1 = new Object( ...

  4. 【转】Android studio 导入github工程

    http://blog.csdn.net/feixiaku/article/details/45155587/ 从github下载两个开源项目: PagerSlidingTabStrip    |   ...

  5. jenkins 每个月1号到7号 一天执行一次

    在线Crontab表达式执行时间验证 / crontab执行时间计算 - aTool在线工具验证 http://www.atool.org/crontab.php 1.Build periodic a ...

  6. php处理ajax请求&comma;ajax&plus;php实现跨域

    第一种方法通过设置Access-Control-Allow-Origin来实现跨域 1.首先要了解什么是域? 什么是域,简单来说就是协议+域名或地址+端口,3者只要有任何一个不同就表示不在同一个域.跨 ...

  7. English trip EM2-LP-4B At School Teacher&colon;Russell

    课上内容(Lesson) Where is Loki a student?  Loki is in Meten, BaobaoStreet, Chengdu. What is he studying? ...

  8. CodeForces Contest &num;1137&colon; Round &num;545 &lpar;Div&period; 1&rpar;

    比赛传送门:CF #1137. 比赛记录:点我. 每次都自闭的 div1 啊,什么时候才能上 IM 呢. [A]Skyscrapers 题意简述: 有一个 \(n\times m\) 的矩阵 \(a_ ...

  9. 如何实现php手机短信验证功能

    http://www.qdexun.cn/jsp/news/shownews.do?method=GetqtnewsdetailAction&id=1677 下载php源代码 现在网站在建设网 ...

  10. 解决UITableView在iOS7中UINavigationController里的顶部留白问题

    解决UITableView在iOS7中UINavigationController里的顶部留白问题 出现问题时候的截图: 源码: 用到的类: UIViewController+TitleTextAtt ...