HDU4310:Hero
Problem 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.
10 2
2
100 1
1 100
201
#include <iostream>
#include <algorithm> using namespace std; struct node
{
double hp;
double dps;
double bi;
} data[]; bool cmp(const node &a,const node &b)
{
if(a.bi>b.bi)
return true;
else if(a.bi==b.bi)
{
if(a.dps<b.dps)
return true;
else return false;
}
else return false;
} int main()
{
int n;
double ans;
while(cin>>n)
{
ans=;
for(int i=;i<n;i++)
{
cin>>data[i].hp>>data[i].dps;
data[i].bi=data[i].dps/data[i].hp*1.0;
}
sort(data,data+n,cmp);
for(int i=;i<n;i++)
{
while(data[i].hp)
{
for(int j=i;j<n;j++)
ans+=data[j].dps;
data[i].hp--;
}
}
cout<<ans<<endl;
}
return ;
}
HDU4310:Hero的更多相关文章
- BZOJ3864 & HDU4899:Hero meet devil——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=3864 http://acm.hdu.edu.cn/showproblem.php?pid=4899 ...
- 2020网鼎杯 白虎组reverse:hero
主函数,当bossexist的值不为0时,while循环dround()函数,循环结束输出flag outflag()函数的flag值由6段数据拼凑而成 while循环的dround()函数有三个选择 ...
- Cocos2dx游戏开发系列笔记13:一个横版拳击游戏Demo完结篇
懒骨头(http://blog.csdn.net/iamlazybone QQ:124774397 ) 写下这些东西的同时 旁边放了两部电影 周星驰的<还魂夜> 甄子丹的<特殊身份& ...
- switch语句:适用于一个条件有多个分支的情况---分支语句
例1: 客服选择功能,然后按按键 Console.WriteLine("查花费请按1,查余额请按2,查流量请按3,办理业务请按4,宽带请按5,人工服务请按6,集团业务请按7"); ...
- Angular 2.0 基础:服务
什么是服务(Service) 在Angular 2 中我们提到的服务 service 一般指的是 哪些能够被其他组件或者指令调用的 单一的,可共享的 代码块.当然,通过服务可以将数据和组件分开,这样就 ...
- BZOJ5336:[TJOI2018]游园会——题解
https://www.lydsy.com/JudgeOnline/problem.php?id=5336 https://www.luogu.org/problemnew/show/P4590 小豆 ...
- python27期day13:闭包、装饰器初始、标准版装饰器、作业题
1.闭包: 保护数据安全.保护数据干净性. 2.闭包的定义:在嵌套函数内.使用非全局变量(且不使用本层变量) 将嵌套函数返回 闭包的目的:要接受被装饰的函数和被装饰函数需要的参数3.闭包举例子: de ...
- [开发ing] Unity项目 - Hero英雄
目录 游戏原型 项目演示 绘图资源 代码实现 技术探讨 参考来源 游戏原型 游戏介绍:这是一款横版类魂游戏,玩家将操控Hero,在诸神黄昏的墓地中,挑战源源不断的敌人,以及近乎无敌的强大boss 灵感 ...
- Django(五)1 - 4章实战:从数据库读取图书列表并渲染出来、通过url传参urls.py path,re_path通过url传参设置、模板语法
一.从数据库读取图书数据并渲染出来 1)app1/views.py函数books编写 [1]从模型下导入bookinfo信息 [2]从数据库获取图书对象列表 [3]把获取到的图书对象赋值给books键 ...
随机推荐
- SSH整合例子
三大框架: Struts框架 1. params拦截器: 请求数据封装 2. 类型转换/数据处理 3. struts配置 4. 文件上传/下载/国际化处理 5. 数据效验/拦截器 6. Ognl表达式 ...
- ACE Socket Wrapper Facade
ACE Socket Wrapper Facade 1:Socket API 1.1 IPC(进程间通信) IPC分为本地IPC(同一计算机上的不同进程)和远程IPC(网络互联的不同计算机),本地IP ...
- Jquery 返回顶部
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- 分布式版本控制系统Git-----1.Git 初识
开始工作咯,师傅让我开始学习Git.刚接触我是懵逼的,"分布式版本控制系统"啥玩意啊这是,大家可不能从字面意思上理解啊,刚开始,版本控制么,我以为是团队合作的时候把开发工具.JDK ...
- 微信小程序学习总结(1)
1.一个小程序文件最基本包含app.js.app.json.app.wxss和pages文件夹结构,pages中的页面必须要在app.json的pages项进行配置,app.json也提供窗口表现,t ...
- gitlab自动备份
1.周期性计划任务: $crontab -e 0 0 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create $service crond res ...
- Var x;---定义变量
变量定义有多种格式 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...
- 强大DOM选择器querySelector
今天碰到问题,用了下不经常用的querySelector还不错 querySelector 和 querySelectorAll 的使用非常的简单,就像标题说到的一样,它和 CSS 的写法完全一样,对 ...
- JS的一些常见验证代码
1//檢查空串 2function isEmpty(str){ 3 if((str == null)||(str.length == 0)) return (true); 4 else retu ...
- Graph Algorithm
1.定义 A graph consists of a set of vertices V and a set of edges E. Each edge is a pair (v, w), where ...