2019 GDUT Rating Contest I : Problem B. Teamwork
题面:
B. Teamwork
1
15
7
9
2
5
10
题目描述:
题目分析:



1 #include <cstdio>
2 #include <cstring>
3 #include <iostream>
4 #include <cmath>
5 #include <algorithm>
6 using namespace std;
7 const int maxn = 1e4+5;
8 const int maxk = 1e3+5;
9 int n, k;
10 int a[maxn];
11 int dp[maxn];
12
13 void test(){
14 cout << endl;
15 for(int i = 1; i <= n; i++){
16 printf("dp[%d] = %d\n", i, dp[i]);
17 }
18 }
19
20 int main(){
21 scanf("%d%d", &n, &k);
22 for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
23
24
25 for(int i = 1; i <= n; i++){
26 int pre_max = 0;
27 for(int j = 1; j <= k; j++){
28 if(i >= j){
29 if(a[i-j+1] > pre_max) pre_max = a[i-j+1];
30 dp[i] = max(dp[i], dp[i-j]+pre_max*j);
31 }
32 }
33 }
34
35 //test();
36 printf("%d\n", dp[n]);
37 return 0;
38 }
2019 GDUT Rating Contest I : Problem B. Teamwork的更多相关文章
- 2019 GDUT Rating Contest II : Problem F. Teleportation
题面: Problem F. Teleportation Input file: standard input Output file: standard output Time limit: 15 se ...
- 2019 GDUT Rating Contest III : Problem D. Lemonade Line
题面: D. Lemonade Line Input file: standard input Output file: standard output Time limit: 1 second Memo ...
- 2019 GDUT Rating Contest I : Problem H. Mixing Milk
题面: H. Mixing Milk Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest I : Problem A. The Bucket List
题面: A. The Bucket List Input file: standard input Output file: standard output Time limit: 1 second Me ...
- 2019 GDUT Rating Contest I : Problem G. Back and Forth
题面: G. Back and Forth Input file: standard input Output file: standard output Time limit: 1 second Mem ...
- 2019 GDUT Rating Contest III : Problem E. Family Tree
题面: E. Family Tree Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest III : Problem C. Team Tic Tac Toe
题面: C. Team Tic Tac Toe Input file: standard input Output file: standard output Time limit: 1 second M ...
- 2019 GDUT Rating Contest III : Problem A. Out of Sorts
题面: 传送门 A. Out of Sorts Input file: standard input Output file: standard output Time limit: 1 second M ...
- 2019 GDUT Rating Contest II : Problem G. Snow Boots
题面: G. Snow Boots Input file: standard input Output file: standard output Time limit: 1 second Memory ...
随机推荐
- 鸟哥的linux私房菜——第十二章学习(Shell Scripts)
第十二章 Shell Scripts 1.0).什么是shell scripts? script 是"脚本.剧本"的意思.整句话是说, shell script 是针对 shel ...
- Leetcode(25)- k个一组翻转链表
给出一个链表,每 k 个节点一组进行翻转,并返回翻转后的链表. k 是一个正整数,它的值小于或等于链表的长度.如果节点总数不是 k 的整数倍,那么将最后剩余节点保持原有顺序. 示例 : 给定这个链表: ...
- 对于kmp求next数组的理解
首先附上代码 1 void GetNext(char* p,int next[]) 2 { 3 int pLen = strlen(p); 4 next[0] = -1; 5 int k = -1; ...
- 解决debian (Friendly ARM 嵌入式板)的sudo等一部分命令无法TAB补全
TAB对于比较长的命令在使用时是十分方便的,最近就遇到TAB 键无法补全sudo后跟的命令的情况因此去网上取经.在一篇博客中找到解决问题的方法,觉得大牛们写的太精炼然后自己做如下总结方便自已以后解决类 ...
- 如何在 Apple Watch S6上离线播放音乐
如何在 Apple Watch S6上离线播放音乐 Apple Watch 离线播放音乐 营销策略,捆绑销售 Apple Watch + AirPods + Apple Music Apple Wat ...
- frontends tools
frontends tools figma free online UI 可视化埋点 https://www.figma.com/files/recent cypress testing $ npm ...
- @bind decorator
@bind decorator https://www.npmjs.com/package/bind-decorator https://github.com/NoHomey/bind-decorat ...
- how to overwrite css !important style
how to overwrite css !important style css !important bug how to override css !important style https: ...
- 打造NGK生态星空计划,高倍币VAST即将震撼上线!
援引华盛顿邮报.彭博社.路透社以及CNN等知名媒体的报道,NGK官方近日宣布,为了完善NGK生态星空计划,NGK官方近日即将推出SPC的子币VAST,以鼓励更多的生态建设者参与. NGK官方相关负责人 ...
- 如何把数据放到C#的心里之 DB2实例
平时偶尔因为工作需要得自己写一些小工具去操作数据库,因为只是需要实现一些小的功能,也不涉及多类型的数据库,也许就是一次性的使用.所以此时那些大而全的数据库操作框架,也就不再那么适合我了.而本篇博文主要 ...