【动态规划】Überwatch
Überwatch
题目描述
Sadly, you aren’t very good at these kind of games. However, Überwatch offers more than just skill based gameplay. In Überwatch you can defeat all opponents in view with a single button press using your ultimate attack. The drawback of this attack is that it has to charge over time before it is ready to use. When it is fully charged you can use it at any time of your choosing.
After its use it immediately begins to charge again.
With this knowledge you quickly decide on a strategy:
• Hide from your opponents and wait for your ultimate attack to charge.
• Wait for the right moment.
• Defeat all opponents in view with your ultimate attack.
• Repeat.
After the game your teammates congratulate you on your substantial contribution. But you wonder: How many opponents could you have defeated with optimal timing?
The game is observed over n time slices. The ultimate attack is initially not charged and requires m time slices to charge. This first possible use of the ultimate attack is therefore in the (m+1)-th time slice. If the ultimate attack is used in the i-th time slice, it immediately begins charging again and is ready to be fired in the (i + m)-th time slice.
输入
• one line with two integers n and m, where
– n (1 ≤ n ≤ 300 000) is the game duration;
– m (1 ≤ m ≤ 10) is the time needed to charge the ultimate attack in time slices.
• one line with n integers xi (0 ≤ xi ≤ 32) describing the number of opponents in view during a time slice in order.
输出
样例输入
4 2
1 1 1 1
样例输出
1
【题解】
题意说,有一个大招每次放完还需要等待m次,直接考虑dp[i],从开始到i这个时间内获取的最大值。
注意:第一个位置的时候为0,然后如果放完大招后下一次充能从1开始。【题目说得很清楚】
然后直接转移即可。
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5+;
int dp[N],a[N],n,m;
int main()
{
scanf("%d%d",&n,&m);
//m++;
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
int res = ;
for(int i=;i<=n;i++){
dp[i] = dp[i-] ;
if( i>=(m+) ){
dp[i] = max( dp[i-m] + a[i] , dp[i] );
res = max( res , dp[i]) ;
}
}
printf("%d\n",res );
return ;
}
【动态规划】Überwatch的更多相关文章
- 增强学习(三)----- MDP的动态规划解法
上一篇我们已经说到了,增强学习的目的就是求解马尔可夫决策过程(MDP)的最优策略,使其在任意初始状态下,都能获得最大的Vπ值.(本文不考虑非马尔可夫环境和不完全可观测马尔可夫决策过程(POMDP)中的 ...
- 简单动态规划-LeetCode198
题目:House Robber You are a professional robber planning to rob houses along a street. Each house has ...
- 动态规划 Dynamic Programming
March 26, 2013 作者:Hawstein 出处:http://hawstein.com/posts/dp-novice-to-advanced.html 声明:本文采用以下协议进行授权: ...
- 动态规划之最长公共子序列(LCS)
转自:http://segmentfault.com/blog/exploring/ LCS 问题描述 定义: 一个数列 S,如果分别是两个或多个已知数列的子序列,且是所有符合此条件序列中最长的,则 ...
- C#动态规划查找两个字符串最大子串
//动态规划查找两个字符串最大子串 public static string lcs(string word1, string word2) { ...
- C#递归、动态规划计算斐波那契数列
//递归 public static long recurFib(int num) { if (num < 2) ...
- 动态规划求最长公共子序列(Longest Common Subsequence, LCS)
1. 问题描述 子串应该比较好理解,至于什么是子序列,这里给出一个例子:有两个母串 cnblogs belong 比如序列bo, bg, lg在母串cnblogs与belong中都出现过并且出现顺序与 ...
- 【BZOJ1700】[Usaco2007 Jan]Problem Solving 解题 动态规划
[BZOJ1700][Usaco2007 Jan]Problem Solving 解题 Description 过去的日子里,农夫John的牛没有任何题目. 可是现在他们有题目,有很多的题目. 精确地 ...
- POJ 1163 The Triangle(简单动态规划)
http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
随机推荐
- ICEM-轴(周期复制网格)
原视频下载地址:https://yunpan.cn/cqMnfpqQQdZZI 访问密码 802b
- GO make&new区别
自:http://www.cnblogs.com/ghj1976/archive/2013/02/12/2910384.html 1.make用于内建类型(map.slice 和channel)的内存 ...
- GO 类型断言
在Go语言中,我们可以使用type switch语句查询接口变量的真实数据类型,语法如下: switch x.(type) { // cases } x必须是接口类型. 来看一个详细的示例: type ...
- ISA真慢
计划没有变化快,周一计划的任务几乎没怎么做,时间完全交给了一个BUG: 最近大家在做新主板的功能,同事说DeviceNet不通,尽管我对DeviceNet一点不懂,不过好歹之前测过CAN模块在新主板上 ...
- javascript中的contains方法和compareDocumentPosition方法
IE有许多好用的方法,后来都被其他浏览器抄袭了,比如这个contains方法.如果A元素包含B元素,则返回true,否则false.唯一不支持这个方法的是IE的死对头firefox.不过火狐支持com ...
- Go 语言入门(二)方法和接口
写在前面 在学习 Go 语言之前,我自己是有一定的 Java 和 C++ 基础的,这篇文章主要是基于A tour of Go编写的,主要是希望记录一下自己的学习历程,加深自己的理解 Go 语言入门(二 ...
- osg qt fbx
void TeslaManage::loadModelFile(QString &filename) { file_node = osgDB::readNodeFile(std::string ...
- 在Springmvc普通类@Autowired注入request为null解决方法
在Springmvc普通类@Autowired注入request为null解决方法 在类中加入以下注入request对象的代码,运行时发现request为null,注入失败.在@Controlle ...
- 【实验】ssh私钥泄露
翻自己的笔记看到之前做过的一个实验,一个关于ssh私钥泄露的实验,贴出来与大家交流. 做这种题脑洞需要特别大,而且也需要运气. 1.实验环境准备 2.实验流程 1)探测信息 用namp进行端口扫描,扫 ...
- Arduino图形化编程软件ArduBlock的安装过程
ArduBlock是一款图形编程插件,接下来我们在Windows10上进行安装 注意ArduBlock虽然能安装在1.83版本的Ardunio上,但在载入程序时会报错,用本身的IDE不会出现这种情况. ...