Codeforces 467C George and Job(dp)
来源:互联网 发布:画派 知乎 编辑:程序博客网 时间:2024/05/29 13:23
题目链接:Codeforces 467 George and Job
题目大意:给定一个长度为n的序列,从序列中选出k个不重叠且连续的m个数,要求和最大。
解题思路:dp[i][j]表示到第i个位置选了j个子序列。
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long ll;const int maxn = 5005;int N, M, K;ll arr[maxn], sum[maxn];ll dp[maxn][maxn];ll solve () { ll ret = 0; for (int i = M; i <= N; i++) { ll tmp = sum[i] - sum[i-M]; for (int j = 1; j <= K; j++) dp[i][j] = max(dp[i-1][j], dp[i-M][j-1] + tmp); ret = max(ret, dp[i][K]); } return ret;}int main () { scanf("%d%d%d", &N, &M, &K); for (int i = 1; i <= N; i++) { scanf("%lld", &arr[i]); sum[i] = sum[i-1] + arr[i]; } printf("%lld\n", solve()); return 0;}
题目链接:Codeforces 467 George and Job
题目大意:给定一个长度为n的序列,从序列中选出k个不重叠且连续的m个数,要求和最大。
解题思路:dp[i][j]表示到第i个位置选了j个子序列。
阅读全文
1 0
- codeforces 467C George and Job dp
- Codeforces 467C George and Job(dp)
- Codeforces 467C George and Job(dp)
- Codeforces 467C George and Job(dp)
- codeforces-467C-George and Job【dp】
- [CodeForces 467C]George and Job[DP]
- Codeforces 467C George and Job DP
- Codeforces 467C George and Job(dp)
- Codeforces 467C George and Job【dp】好题~
- codeforces 467-C. George and Job(前缀和+dp)
- Codeforces 467C. George and Job
- Codeforces 467C George and Job
- codeforces 467C - George and Job
- Codeforces 467 C. George and Job
- CodeForces - 467C George and Job
- CodeForces 467C George and Job
- 【DP】 467C George and Job
- 【CF】 467C George and Job DP
- 入门篇(4)NAO机器人接力赛通信问题
- [iOS]自定义日历选择
- CDH集群环境要求
- Jquery之Ajax实例_登录
- 基于用户投票的排名算法:威尔逊区间
- Codeforces 467C George and Job(dp)
- PCB设计注意事项
- nodejs+layui+laytpl实现分页的例子
- activity活动的四种启动模式
- swift Data 扩展
- Java-abstract(抽象)、final、static
- Dubbo入门学习--Dubbo服务提供接口SPI机制
- iOS之《Effective Objective-C 2.0》读书笔记(14)
- spark的transformation和action算子(基本操作)