暑假集训(2)第八弹 ----- Hero(hdu4310)
Crawling in process... Crawling failed Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
There are two key attributes for the heroes in the game, health point (HP) and damage per shot (DPS). Your hero has almost infinite HP, but only 1 DPS.
To simplify the problem, we assume the game is turn-based, but not real-time. In each round, you can choose one enemy hero to attack, and his HP will decrease by 1. While at the same time, all the lived enemy heroes will attack you, and your HP will decrease by the sum of their DPS. If one hero's HP fall equal to (or below) zero, he will die after this round, and cannot attack you in the following rounds.
Although your hero is undefeated, you want to choose best strategy to kill all the enemy heroes with minimum HP loss.
Input
Output
Sample Input
10 2
2
100 1
1 100
Sample Output
201
#include "iostream"
#include "algorithm" using namespace std;
struct enemy
{
int hp;
int dp;
};
enemy N[];
enemy T[];
int sum;
__int64 dead;
void ebegin(int n)
{
for (int i=;i<=n;i++)
{
cin>>N[i].dp>>N[i].hp;
sum += N[i].dp;
}
}
void defeat (int n)
{
for (int i=;i<=n;i++)
{
dead += sum * N[i].hp;
sum -= N[i].dp;
}
cout<<dead<<endl;
}
int compare (enemy x,enemy y)
{
return x.hp * y.dp < x.dp * y.hp;
}
int main()
{
int n;
while (cin>>n)
{
dead = ;
ebegin(n);
sort(N+,N+n+,compare);
defeat(n);
}
return ;
}
暑假集训(2)第八弹 ----- Hero(hdu4310)的更多相关文章
- 暑假集训(4)第八弹——— 组合(hdu1524)
题意概括:你已经赢得两局,最后一局是N个棋子往后移动,最后一个无法移动的玩家失败. 题目分析:有向无环图sg值游戏,尼姆游戏的抽象表达.得到每个棋子的sg值之后,把他们异或起来,考察异或值是否为0. ...
- 暑假集训(1)第八弹 -----简单迷宫(Poj3984)
Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, ...
- 暑假集训(3)第四弹 -----Frogger(Poj2253)
题意梗概:青蛙王子最近喜欢上了另一只经常坐在荷叶上的青蛙公主.不过这件事不小心走漏了风声,被某fff团团员知 道了,在青蛙王子准备倾述心意的那一天,fff团团员向湖泊中注入大量的充满诅咒力量的溶液.这 ...
- 暑假集训(2)第七弹 -----今年暑假不AC(hdu2037)
J - 今年暑假不AC Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:32768KB 64 ...
- 暑假集训(4)第五弹——— 数论(hdu1222)
题意概括:那天以后,你好说歹说,都快炼成三寸不烂之舍之际,小A总算不在摆着死人脸,鼓着死鱼眼.有了点恢复的征兆.可孟子这家伙说的话还是有点道理,那什么天将降....额,总之,由于贤者法阵未完成,而小A ...
- 暑假集训(4)第七弹——— 组合(hdu1850)
题意概括:你赢得了第一局.魔鬼给出的第二局是,如果有N堆牌,先手的人有几种可能胜利. 问题分析:尼姆游戏,先得到n堆牌的数量异或和,再将异或和与每一个牌组的数量异或,如果结果小于原牌组数量 则可能++ ...
- 暑假集训(4)第六弹——— 组合(poj1067)
题意概括:上一次,你成功甩掉了fff机械兵.不过,你们也浪费了相当多的时间.fff团已经将你们团团包围,并且逐步 逼近你们的所在地.面对如此危机,你不由得悲观地想:难道这acm之路就要从此中断?虽然走 ...
- 暑假集训(4)第四弹 -----排列,计数(hdu1465)
题意概括:嗯,纵使你数次帮助小A脱离困境,但上一次,小A终于还是失败了.那数年的奔波与心血,抵不过轻轻一指,便彻底 湮灭,多年的友谊终归走向末路.这一切重击把小A彻底击溃! 不为什么,你到底还是要继续 ...
- 暑假集训(4)第三弹 -----递推(Hdu1799)
问题描述:还记得正在努力脱团的小A吗? 他曾经最亲密的战友,趁他绘制贤者法阵期间,暗中设下鬼打墙将小A 围困,并准备破坏小A正在绘制的法阵.小A非常着急.想阻止他的行动.而要阻止他,必须先破解鬼打墙. ...
随机推荐
- 在C#中实现软件自动升级
在C#中实现软件自动升级 winform程序相对web程序而言,功能更强大,编程更方便,但软件更新却相当麻烦,要到客户端一台一台地升级,本文结合实际情况,通过软件实现自动升级,弥补了这一缺陷,有较好的 ...
- [威客任务]¥800.00 JS实现网站联动三级选项
任务地址:http://task.zhubajie.com/3275832/ 具体要求: 要求1) 选单样式参照附件2) 点击第一个选项内容后,跳出第二个选项栏位,并自动更新选项内容3) 点击第二个选 ...
- How good software makes us stupid?
How good software makes us stupid? 科技是怎样让人变傻的? People assume that iPhones, laptops and Netflix are e ...
- Android虚拟环境的工具集Genymotion完整安装教程
Genymotion提供Android虚拟环境的工具集.相信很多Android开发者一定受够了速度慢.体验差效率及其地下的官方模拟器了.如果你没有物理机器,又不想忍受官方模拟器的折磨,Genymoti ...
- 安装builderRobot到Rational Functional Tester和Performance Tester
最近研究安装builder,稍微总结一下,以后继续补充: 1. Robot采用专业的测试脚本语言, 从而导致需要学习专门的API以及专门的语法外, 用进程化的Visual Basic作为脚本语言, 导 ...
- NodeJs + gm图片缩略图
我的另一篇文章: Nginx/Apache图片缩略图技术 gm官网 1, 软件环境 nodejs npm GraphicsMagick or ImageMagick 貌似ImageMagick在处理大 ...
- [Web] What Is JSONP?
JSONP—or JSON with padding—is a sneaky technique that web developers came up with to work around the ...
- Ubuntu10.04下载并编译Android4.3源代码
注:转载或引用请标明出处 http://blog.csdn.net/luzhenrong45/article/details/9719433 去年用Ubuntu10.10成功下载并编译Andro ...
- eclipse中不能找到dubbo.xsd解决方法
使用dubbo时遇到问题: org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'htt ...
- 学通javaweb 24堂课 学习笔记
17.01:简单配置控制器 1.一个controller protected ModelAndView handleRequestInternal(HttpServletRequest request ...