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 ...
随机推荐
- Win10 Nodejs搭建http-server注意点
下载安装,并用命令行查看版本:如果提示输入命令找不到等,可能是没有安装成功,或者是环境变量引起的: 如果在提示安装不成功可能是win10权限问题,最好使用管理员模式运行cmd,再用cmd命令打开安装文 ...
- nodejs非安装版配置(windows)
nodejs官网下载地址: https://nodejs.org/en/download/ 解压到本地并配置环境变量 在环境变量path中新增 D:\develop\node 查看是否配置成功 至此n ...
- LaTex公式在线转图片
Reference https://latex.codecogs.com/gif.latex?THE_FORMULAR 注: 请不要包含空格 或者 将整段url放到浏览器里, 会产生空格等字符的替换, ...
- js 十大排序算法 All In One
js 十大排序算法 All In One 快速排序 归并排序 选择排序 插入排序 冒泡排序 希尔排序 桶排序 堆排序(二叉树排序) 基数排序 计数排序 堆排序(二叉树排序) https://www.c ...
- css3 & content & attr & data-*
css3 & content & attr & data-* content: attr(data-value); https://github.com/oliviale/CS ...
- svg opacity & fill-opacity & stroke-opacity
svg opacity & fill-opacity & stroke-opacity opacity = ill-opacity + stroke-opacity https://s ...
- uniapp 发起网络请求
推荐下我写的uni-http 创建http-config.js import Vue from 'vue' const BASE_URL = 'http://xxx.com'; if (process ...
- [报错集]ubuntu中安装oracle java报错
1.因为版本更新,JAVA15以前的版本都已经没办法下载了,所以要使用oracle java必须使用最近的java15 $ sudo apt-get install oracle-java15-ins ...
- http接口的学习(暂时只是记录,测试之后重新更新)
链接1:https://blog.csdn.net/java173842219/article/details/54020168 链接2:https://blog.csdn.net/u01132074 ...
- 微信小程序:block标签
代码中存在block标签,但是渲染的时候会移除掉. 例子: 如果将view改为block: 当你要渲染某些数据时,如果不想额外的加一层外边的标签,此时可以使用block标签来进行占位.