博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu---(4310)Hero(贪心算法)
阅读量:7226 次
发布时间:2019-06-29

本文共 1826 字,大约阅读时间需要 6 分钟。

Hero

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 2606    Accepted Submission(s): 1169

Problem 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
 

 

Author
TJU
 

 

Source
 
代码:先是模拟,然后优化,之后得到这么一个jiahuo ....
1 #include
2 #include
3 #include
4 using namespace std; 5 struct node{ 6 int HP,DSP; 7 bool operator < (const node & a)const{ 8 return DSP*a.HP>a.DSP*HP; 9 }10 };11 node st[22];12 int main(){13 14 int n;15 int ans;16 // freopen("test.in","r",stdin);17 while(scanf("%d",&n)!=EOF){18 ans=0;19 for(int i=0;i
View Code

 

转载地址:http://ikdfm.baihongyu.com/

你可能感兴趣的文章
文件夹工具类 - FolderUtils
查看>>
http://blog.csdn.net/huang_xw/article/details/7090173
查看>>
lua学习例子
查看>>
研究:印度气候变暖速度加剧 2040年或面临重灾
查看>>
python爬虫——爬取豆瓣TOP250电影
查看>>
C++与Rust操作裸指针的比较
查看>>
了解webpack-4.0版本(一)
查看>>
如何培养良好的编程风格
查看>>
Netty Channel源码分析
查看>>
基于 HTML5 WebGL 的 3D 机房
查看>>
Java编程——数据库两大神器:索引和锁
查看>>
springMvc学习笔记(2)
查看>>
吐槽Javascript系列二:数组中的splice和slice方法
查看>>
什么是Javascript函数节流?
查看>>
MQ框架的比较
查看>>
oschina
查看>>
Octave 入门
查看>>
深度学习入门:10门免费线上课程推荐
查看>>
React组件设计模式(一)
查看>>
E-HPC支持多队列管理和自动伸缩
查看>>