The Last Stand
The Last Stand
https://ac.nowcoder.com/acm/contest/303/L
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
当刀锋女王的生命值小于等于0时,她就会死亡,在保证刀锋女王必须存活的条件下。她到达人族基地时的最大生命值是多少?(假设她的生命值上限无限大的前提下)
输入描述:
第一行输入一个正整数T(1≤T≤30),表示有T组数据。 对于每组案例: 第一行输入三个正整数n,m,h(1≤n≤1000,1≤m≤10^9,1≤h≤10^9)分别表示有n个事件的触发地,刀锋女王要进攻位于m处的人族基地,刀锋女王的初始生命h。 接下来n行每行输入三个正整数pos[i],val[i],delta[i](1≤pos[i]<m ,-10^9≤val[i],delta[i]≤10^9),分别表示第i个事件的触发地为pos[i],如果刀锋女王触发该事件的话,会立刻改变她的生命val[i]点,并且会改变自身buff的状态,之后每往前走一步都会改变她的生命值delta[i]点。 输入保证这n个事件的触发地pos[i]是按照递增顺序输入的,并且pos[i]互不相同。
输出描述:
对于每组数据,请输出一行一个正整数表示刀锋女王在选择最优策略的情况下到达人族基地时自身生命的最大值。
输入例子:
4
3 5 1
1 -1 100000
2 200 -100
3 -100 2
4 10 1
1 -1 100
2 50 -10
4 -15 3
5 -20 5
4 100 1
1 -1 100
2 50 -10
4 -15 3
5 -20 5
1 1000000000 1
1 900000000 -1
输出例子:
5
34
476
1
-->
输入
4
3 5 1
1 -1 100000
2 200 -100
3 -100 2
4 10 1
1 -1 100
2 50 -10
4 -15 3
5 -20 5
4 100 1
1 -1 100
2 50 -10
4 -15 3
5 -20 5
1 1000000000 1
1 900000000 -1
输出
5
34
476
1
说明
第一组样例: 当刀锋女王走到1位置时如果选择触发事件就会立刻失去1点生命而导致死亡,所以她不能触发事件1。 之后刀锋女王走到位置2,她选择触发事件,她先获得200点生命值,所以当前生命值变为201,并且身上获得了一个每走一步生命减少100点的debuff。 刀锋女王走到位置3时由于debuff的效果生命减少100点变为101,之后她选择触发位置3上的事件,生命值先减少100点变为1,并且身上获得了一个每走一步生命值增加2的buff效果,并且该效果覆盖掉了之前的debuff。 刀锋女王从位置3走到位置4,触发一次buff效果,当前生命变为3。 刀锋女王从位置4走到位置5,再次触发buff效果,当前生命变为5。
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<vector>
typedef long long ll;
using namespace std; struct sair{
ll pos,val,delta;
}a[]; ll dp[]; int main(){ ll n,m,h;
int _;
for(cin>>_;_;_--){
cin>>n>>m>>h;
for(int i=;i<=n;i++){
cin>>a[i].pos>>a[i].val>>a[i].delta;
}
a[n+].pos=m,a[n+].val=,a[n+].delta=;
for(int i=;i<=n+;i++){
dp[i]=h;
}
for(int i=;i<=n;i++){
ll tmp=dp[i]+a[i].val;
if(tmp>){
for(int j=i+;j<=n+;j++){
tmp=dp[i]+a[i].val+(a[j].pos-a[i].pos)*a[i].delta;
dp[j]=max(dp[j],tmp);
}
}
}
cout<<dp[n+]<<endl;
} }
The Last Stand的更多相关文章
- uva 11174 Stand in a Line
// uva 11174 Stand in a Line // // 题目大意: // // 村子有n个村民,有多少种方法,使村民排成一条线 // 使得没有人站在他父亲的前面. // // 解题思路: ...
- Linux中的两种守护进程stand alone和xinetd
Linux中的两种守护进程stand alone和xinetd --http://www.cnblogs.com/itech/archive/2010/12/27/1914846.html#top 一 ...
- 数学:UVAoj 11174 Stand in a Line
Problem J Stand in a Line Input: Standard Input Output: Standard Output All the people in the bytela ...
- Xtreme9.0 - Taco Stand 数学
Taco Stand 题目连接: https://www.hackerrank.com/contests/ieeextreme-challenges/challenges/taco-stand Des ...
- 【linux】【进程】stand alone 与 super daemon 区别
本文引用自 鸟哥的linux私房菜如果依据 daemon 的启动与管理方式来区分,基本上,可以将 daemon 分为可独立启动的 stand alone , 与透过一支 super daemon 来 ...
- Statelessness Provide credentials with the request. Each request MUST stand alone and should not be affected from previous conversation happened from same client in past.
The server never relies on information from previous requests. Statelessness As per the REST (REpres ...
- [转]ORA-38500: USING CURRENT LOGFILE option not available without stand
标签: oracle 10g 数据库 ora-38500 it 分类: IT author:skate time :2009/08/03 在dataguard启用实时恢复的时候,报如下错误: ORA- ...
- stand up meeting 12-3
因为前后端在参数传递定义不清晰的原因,今天士杰和国庆采用了pair programming的方法,在一台电脑前工作了四十分钟,明确了请求questionpool,请求question,请求rank d ...
- stand up meeting 12-2
今天因为各位组员组里项目原因没有集中在一起进行stand up meeting.但是士杰和天赋国庆分别对项目进度和前后端的结合进行的沟通. 针对后端部分,天赋完成了GetRankingData API ...
随机推荐
- tsql 循环id读取
declare @IDList as varchar(max) declare @ID as int declare @i as int set @IDList='' )) + ',' from ta ...
- iframe引入百度地图显示企业位置
步骤一:打开下面这个地址:http://api.map.baidu.com/lbsapi/creatmap/index.html 步骤二:定位中心点 在打开的页面左侧,输入企业的详细地 ...
- 在docker中运行kong和kong dashboard
一.制作alpine版的kong镜像 https://github.com/Kong/docker-kong/tree/d4cec3dc46c780a916a40963309554ca81da2b46 ...
- Spring Security编程模型
1.采用spring进行权限控制 url权限控制 method权限控制 实现:aop或者拦截器(本质就是之前之后进行控制)--------------------proxy就是 2.权限模型: 本质理 ...
- php metaphone()函数解析
php metaphone() 函数计算字符串的 metaphone 键,本文章向码农们介绍 php metaphone() 函数的基本用法和实例,需要的码农可以参考一下本文章的方法和实例. 定义和用 ...
- python写一个简单的CMS识别
前言: 收集了一点cms路径,打算在写一个.之前已经写了 有需要的可以自己翻我的博客 思路: 网站添加路径判断是否为200,并且无过滤列表中的字符 代码: import requests import ...
- scrapy与redis分布式组件
Scrapy 和 scrapy-redis的区别 Scrapy 是一个通用的爬虫框架,但是不支持分布式,Scrapy-redis是为了更方便地实现Scrapy分布式爬取,而提供了一些以redis为基础 ...
- aspx后台代码写在前段
合并cs的代码 <%@ Page Language="C#" AutoEventWireup="true" Inherits="System.W ...
- 移动cup
intel处理器M和U H结尾的有什么具体区别 笔记本CPU 酷睿i 系列U M H详解: U 低压版(低电压-性能消减)最低主频:1.7-1.9GHZ M 准电压(笔记本上的电压标准)最低主频:2. ...
- js 获取字符串的 像素 宽度 ----字符串格式化输出
function getLenPx(str, font_size) { var str_leng = str.replace(/[^\x00-\xff]/gi, 'aa').length; retur ...