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 ...
随机推荐
- C++ new delete malloc free
title: C++ new delete malloc free date: 2020-03-10 categories: c++ tags: 语法 C++的new delete malloc fr ...
- Redis-第八章节-应用场景
目录 概述 详解 1.概述 Redis支持五种数据类型:String(字符串).Hash(哈希).List(列表).Set(集合).Zset(有序集合). 2.详解 1.String(字符串) 定义: ...
- js jsonParse
mdn const rx_one = /^[\],:{}\s]*$/; const rx_two = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g; // 匹配 ...
- 「NGK每日快讯」2021.2.2日NGK公链第91期官方快讯!
- 【java】ObjectOutputStream & ObjectInputStream 多次写入发生重复写入相同数据的问题
今日份代码,解决 ObjectOutputStream 多次写入发生重复写入相同数据的问题 核心区别如下: package com.sxd.swapping.objoutputstream; impo ...
- java安全管理器SecurityManager
本文转载自java安全管理器SecurityManager 导语 这是一篇对Java安全管理器入门的文章,目的是简单了解什么是SecurityManager,对管理器进行简单配置,解决简单问题. 比如 ...
- InnoDB -- 行记录格式
本文转载自InnoDB -- 行记录格式 分类 Named File Format InnoDB早期的文件格式(页格式)为Antelope,可以定义两种行记录格式,分别是Compact和Redunda ...
- MySQL 常用命令手册 增删改查大法
一.数据库操作 创建数据库 语法: CREATE DATABASE database_name; 删除数据库 删除数据库务必谨慎!因为执行删除命令后,所有数据将消失. 语法: DROP DATABAS ...
- Django之csrf中间件及auth模块使用
目录 一.基于配置文件的编程思想 1. importlib 模块 2. 配置文件 二.跨站请求伪造(csrf) 1.csrf简介以及由来 2.Django中的csrf中间件如何使用 2.1 普通for ...
- WPF -- 一种实现本地化的方法
本文介绍一种WPF程序实现本地化的方法. 步骤 首先,假设xaml文件中存在一个Button按钮,内容为"按钮",实现本地化的步骤如下: 展开程序的Properties,双击Res ...