【DP】 467C George and Job
来源:互联网 发布:淘宝类目选错了 编辑:程序博客网 时间:2024/05/22 03:11
简单DP。。。每个点有选和不选两种情况,推一下就好了。。。
#include <iostream> #include <queue> #include <stack> #include <map> #include <set> #include <bitset> #include <cstdio> #include <algorithm> #include <cstring> #include <climits>#include <cstdlib>#include <cmath>#include <time.h>#define maxn 5005#define maxm 200005#define eps 1e-10#define mod 10000007#define INF 1e17#define lowbit(x) (x&(-x))#define mp make_pair#define ls o<<1#define rs o<<1 | 1#define lson o<<1, L, mid #define rson o<<1 | 1, mid+1, R typedef long long LL;//typedef int LL;using namespace std;LL qpow(LL a, LL b){LL res=1,base=a;while(b){if(b%2)res=res*base;base=base*base;b/=2;}return res;}LL powmod(LL a, LL b){LL res=1,base=a;while(b){if(b%2)res=res*base%mod;base=base*base%mod;b/=2;}return res;}void scanf(int &__x){__x=0;char __ch=getchar();while(__ch==' '||__ch=='\n')__ch=getchar();while(__ch>='0'&&__ch<='9')__x=__x*10+__ch-'0',__ch = getchar();}LL gcd(LL _a, LL _b){if(!_b) return _a;else return gcd(_b, _a%_b);}// headLL dp[maxn][maxn], sum[maxn];int n, m, k;void read(void){scanf("%d%d%d", &n, &m, &k);for(int i = 1; i <= n; i++) scanf("%I64d", &sum[i]);for(int i = 1; i <= n; i++) sum[i] += sum[i-1];}void work(void){memset(dp, -1, sizeof dp);dp[0][0] = 0;for(int i = 0; i < n; i++)for(int j = 0; j <= k; j++) {if(dp[i][j] == -1) continue;dp[i+1][j] = max(dp[i][j], dp[i+1][j]);if(i + m <= n) dp[i+m][j+1] = max(dp[i+m][j+1], dp[i][j] + sum[i+m] - sum[i]);}printf("%I64d\n", dp[n][k]);}int main(void){read();work();return 0;}
0 0
- 【DP】 467C George and Job
- codeforces 467C George and Job dp
- 【CF】 467C George and Job DP
- Codeforces 467C George and Job(dp)
- CF 467C DP George and Job
- Codeforces 467C George and Job(dp)
- Codeforces 467C George and Job(dp)
- codeforces-467C-George and Job【dp】
- Codeforce 467C. George and Job(DP)
- [CodeForces 467C]George and Job[DP]
- Codeforces 467C George and Job DP
- Codeforces 467C George and Job(dp)
- CF 467C - George and Job (简单区间DP)
- Codeforces 467C George and Job【dp】好题~
- codeforces 467-C. George and Job(前缀和+dp)
- codefores #267C George and Job(dp)
- C. George and Job
- Codeforces 467C. George and Job
- 关于MyEclipse web项目下关联部署java project 和项目外的jar包
- 编程之美-中国象棋将帅问题
- ip查询接口演示示例
- 定点DSP与浮点DSP的比较(定点DSP和浮点DSP的定义)
- C\C++和Lua是如何进行通信的?
- 【DP】 467C George and Job
- 多线程访问网页+高并发测试网站
- This Android SDK requires Android Developer Toolkit version 17.0.0 or above. 问题解决方法
- HiddenHttpMethodFilter
- [Android]Volley源码分析(二)初始化
- Erlang和Golang的几点粗浅的比较
- hdu 1412 {A} + {B} (水题但要注意输出格式)
- Android常用的一些make命令(转载)
- 3.基于DWR推送技术Demo