K - Hero

Crawling in process... Crawling failed Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

When playing DotA with god-like rivals and pig-like team members, you have to face an embarrassing situation: All your teammates are killed, and you have to fight 1vN.

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

The first line of each test case contains the number of enemy heroes N (1 <= N <= 20). Then N lines followed, each contains two integers DPSi and HPi, which are the DPS and HP for each hero. (1 <= DPSi, HPi <= 1000)
 

Output

Output one line for each test, indicates the minimum HP loss.
 

Sample Input

1
10 2
2
100 1
1 100
 

Sample Output

20
201
 
 
问题分析:dota啊,好久没玩过了,真......嗯,先统计出所有敌方造成的伤害,然后用dps/hp(每点生命值造成伤害)作为排序的依据,从大到小依次杀光,每杀一个便让总dp减去被杀的人的dp即可。
 #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)的更多相关文章

  1. 暑假集训(4)第八弹——— 组合(hdu1524)

    题意概括:你已经赢得两局,最后一局是N个棋子往后移动,最后一个无法移动的玩家失败. 题目分析:有向无环图sg值游戏,尼姆游戏的抽象表达.得到每个棋子的sg值之后,把他们异或起来,考察异或值是否为0. ...

  2. 暑假集训(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. 暑假集训(3)第四弹 -----Frogger(Poj2253)

    题意梗概:青蛙王子最近喜欢上了另一只经常坐在荷叶上的青蛙公主.不过这件事不小心走漏了风声,被某fff团团员知 道了,在青蛙王子准备倾述心意的那一天,fff团团员向湖泊中注入大量的充满诅咒力量的溶液.这 ...

  4. 暑假集训(2)第七弹 -----今年暑假不AC(hdu2037)

    J - 今年暑假不AC Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64 ...

  5. 暑假集训(4)第五弹——— 数论(hdu1222)

    题意概括:那天以后,你好说歹说,都快炼成三寸不烂之舍之际,小A总算不在摆着死人脸,鼓着死鱼眼.有了点恢复的征兆.可孟子这家伙说的话还是有点道理,那什么天将降....额,总之,由于贤者法阵未完成,而小A ...

  6. 暑假集训(4)第七弹——— 组合(hdu1850)

    题意概括:你赢得了第一局.魔鬼给出的第二局是,如果有N堆牌,先手的人有几种可能胜利. 问题分析:尼姆游戏,先得到n堆牌的数量异或和,再将异或和与每一个牌组的数量异或,如果结果小于原牌组数量 则可能++ ...

  7. 暑假集训(4)第六弹——— 组合(poj1067)

    题意概括:上一次,你成功甩掉了fff机械兵.不过,你们也浪费了相当多的时间.fff团已经将你们团团包围,并且逐步 逼近你们的所在地.面对如此危机,你不由得悲观地想:难道这acm之路就要从此中断?虽然走 ...

  8. 暑假集训(4)第四弹 -----排列,计数(hdu1465)

    题意概括:嗯,纵使你数次帮助小A脱离困境,但上一次,小A终于还是失败了.那数年的奔波与心血,抵不过轻轻一指,便彻底 湮灭,多年的友谊终归走向末路.这一切重击把小A彻底击溃! 不为什么,你到底还是要继续 ...

  9. 暑假集训(4)第三弹 -----递推(Hdu1799)

    问题描述:还记得正在努力脱团的小A吗? 他曾经最亲密的战友,趁他绘制贤者法阵期间,暗中设下鬼打墙将小A 围困,并准备破坏小A正在绘制的法阵.小A非常着急.想阻止他的行动.而要阻止他,必须先破解鬼打墙. ...

随机推荐

  1. easyui tree在struts1中的使用

    前段时间写过类似的功能,开发环境是struts2,jdk1.6,tomcat 而这次是修改N年前的项目 项目的开发环境为struts1,jdk1.4,weblogic8,比较过时所以就增加了使用eas ...

  2. WinForm程序启动控制台窗口Console

    本文转载:http://blog.csdn.net/oyi319/article/details/5753311 2.WinForm程序和控制台窗口Console 如果你调试过SharpDevelop ...

  3. htm explorer

    链接:https://github.com/450640526/HtmExplorer   最低环境 系统安装了.NET 4.0                地址:http://www.baidu. ...

  4. 0 Explore TreeView

    尽可能接近WINDOWS 8的资源管理器效果(这里只模仿它的效果,处理文件功能不包括在内)   TREEVIEW可以增加空白并且空白处不能单击 重绘三角箭头 重绘选中时的边框和填充色 重绘失去焦点时选 ...

  5. JS之正则表达式验证URL

    function IsURL(str_url){ var strRegex = "^((https|http|ftp|rtsp|mms)?://)" + "?(([0-9 ...

  6. CCCatmullRomTo&CCCatmullRomBy

    注: 云形线(Catmull-Rom curve曲线) 云线(Spline或B-spline)在数学上有很多种类,常用的三阶云线有Hermite, Bezier, Uniform B-spline, ...

  7. How-to Dump Keys from Memcache--reference

    Submitted by Lars Windolf on 19. October 2012 - 21:53 http://lzone.de/dump%20memcache%20keys You spe ...

  8. Linux学习之路:shell变量(一)

    一.变量的显示与设置 1.变量的显示运用echo命令 +$符号: 上图例子显示的是系统变量,咱们可以自己设置变量 2.设置变量运用“=”符号 设置了变量NIU 值为“niunai” 变量设置规则: ( ...

  9. C语言---翻译过程

    c的实现中包括两种环境: 1.翻译环境(translation environment):源程序---->机器指令 2.执行环境(execution environment):执行机器指令 这两 ...

  10. Linux下解决permission denied问题

    由于权限问题,在linux下启动tomcat出现权限permission denied 提示解决方法如下: 1.cd 进入tomcat/bin目录 2.运行下面命令 sudo chmod 777 st ...