【动态规划】Ü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 ...
随机推荐
- ORACLE数据库误删恢复
一.表的恢复 对误删的表,只要没有使用PURGE永久删除选项,那么从flash back区恢复回来希望是挺大的.一般步骤有: 1.从flash back里查询被删除的表 select * from r ...
- 2018-2019-2 网络对抗技术 20165222 Exp 8 Web基础
1.实践内容 (1).Web前端HTML 能正常安装.启停Apache.理解HTML,理解表单,理解GET与POST方法,编写一个含有表单的HTML. 使用service apache2 start启 ...
- js的鼠标右键简单菜单
实现点击鼠标右键时出来菜单代码如下: 主要运用oncontextmenu事件,oncontextmenu 事件在元素中用户右击鼠标时触发并打开上下文菜单. <!DOCTYPE html> ...
- python matplotlib(数据可视化)
吐槽 网上搜了不少matplotlib安装方法(不信,你可以试试.) 我只能说,除了太繁琐,就是没什么用! 如果你是python3.6.5版本 我给你最最最正确的建议: 直接打开cmd,找到pip用命 ...
- rpm包和deb分别是什么?
一.RMP 是 LINUX 下的一种软件的可执行程序,你只要安装它就可以了.这种软件安装包通常是一个RPM包(Redhat Linux Packet Manager,就是Redhat的包管理器),后缀 ...
- Docs-.NET-C#-指南-语言参考-预处理器指令:#undef(C# 参考)
ylbtech-Docs-.NET-C#-指南-语言参考-预处理器指令:#undef(C# 参考) 1.返回顶部 1. #undef(C# 参考) 2018/06/30 #undef 允许你定义一个符 ...
- 自定义控件之Region区域
构造Region 直接构造 public Region(Region region) //复制一个同样的Region变量 public Region(Rect r) public Region(int ...
- 设计-Int(4)和Int(11)谁更美
设计-Int(4)和Int(11)谁更美 [缘起] 大家平时在进行数据库设计的时候,如果遇到需要存储整数类型的数据的时候,通常会优先使用Int这个整数类型,在处理20亿级别的正负数值存储上,Int类型 ...
- bing map for wpf 怎么显示中文地图
添加一下代码: string suriFormat = "http://r2.tiles.ditu.live.com/tiles/r{quadkey}.png?g=41"; Mic ...
- VisualStudio版本号
VisualStudio的工程文件,后面的数字对应的VS的版本号, 71表示的VS2003, 80表示VS2005, 90表示VS2008, 10表示VS2010等.