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 ...
随机推荐
- spring-cloud-netflix-eureka-client
服务注册中心eureka-server已经搭好,我们开始编写一个eureka-client,并提供一个hello服务 一.新建module,选择对应的springcloud模块,pom.xml如下: ...
- range()函数的使用、while循环、for-in循环等
一.range()函数 用于直接生成一个整数序列 创建range对象的三种方式: (1)range(stop) 创建一个(0,stop)之间的整数序列,步长为1 (2)range(start,s ...
- es6 curry function
es6 curry function // vuex getters export const getAdsFilterConfig = (state) => (spreader) => ...
- free video tutorial of Deep Learning
free video tutorial of Deep Learning AI 深度学习/ 机器学习/人工智能 Deep Learning With Deep Learning – a form of ...
- Google Advanced Search Skills
Google Advanced Search Skills site:
- css & auto height & overflow: hidden;
css & auto height & overflow: hidden; {overflow: hidden; height: 100%;} is the panacea! {溢出: ...
- js 获取包含emoji的字符串的长度
let emoji_exp = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ ...
- Baccarat流动性挖矿的收益能否持续?该如何参与Baccarat流动性挖矿?
2020年DeFi市场火热,众多投资机构纷纷入场,分享这场资本盛宴.然而,目前市面上大多数DeFi项目手续费高昂,小资金的投资者无法入市.为了让更多的用户参与其中,NGK推出了Baccarat流动性挖 ...
- 源码分析:Exchanger之数据交换器
简介 Exchanger是Java5 开始引入的一个类,它允许两个线程之间交换持有的数据.当Exchanger在一个线程中调用exchange方法之后,会阻塞等待另一个线程调用同样的exchange方 ...
- JVM线上故障初步简易排查
线上故障主要包括cpu 磁盘 内存 网络等问题 依次排查 1.cpu 1) 先用ps找到进程pid 2) top -H -p pid 找到cpu占用高的线程 3)printf '%x\n' pid 获 ...