Hero
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<stdio.h>
#include<algorithm>
#include<cstring>
using namespace std; struct Enemy
{
int hp;
int dps;
}enemy[]; bool cmp(const Enemy &a,const Enemy &b)
{
return (double)a.dps/(double)a.hp>(double)b.dps/(double)b.hp;
} int main()
{ int n;
while(~scanf("%d",&n))
{ int myhp=;
int alldps=;
memset(enemy,,sizeof(enemy));
for (int i=;i<n;i++)
{
scanf("%d %d",&enemy[i].dps,&enemy[i].hp);
alldps+=enemy[i].dps;
}
sort(enemy,enemy+n,cmp);
for(int i=;i<n;i++)
{
myhp+=enemy[i].hp*alldps;
alldps-=enemy[i].dps;
}
printf("%d\n",myhp);
}
return ;
}
Hero的更多相关文章
- H5游戏开发之Stick Hero
自从上次发布一个小恐龙游戏以后,到现在10天了,前后又写了3个游戏,挑了一个感觉比较有挑战的游戏和大家分享一下. 效果演示 这是我模拟一个苹果游戏<stick hero>游戏写的一个小游戏 ...
- BZOJ 1191 超级英雄 Hero 题解
BZOJ 1191 超级英雄 Hero 题解 Description 现在电视台有一种节目叫做超级英雄,大概的流程就是每位选手到台上回答主持人的几个问题,然后根据回答问题的多少获得不同数目的奖品或奖金 ...
- 2016HUAS暑假集训训练2 K - Hero
题目链接:http://acm.hust.edu.cn/vjudge/contest/121192#problem/K 这也是一道贪心题,刚开始写时以为只要对每一敌人的攻击和血的乘积进行从小到大排序即 ...
- 【入门】匈牙利算法+HNOI2006 hero超级英雄
一.关于匈牙利算法 匈牙利算法是由匈牙利数学家Edmonds提出的,用增广路径求二分图最大匹配的算法. 听起来高端,其实说白了就是: 假设不存在单相思(单身狗偷偷抹眼泪),在一个同性恋不合法的国家里( ...
- 2016HUAS_ACM暑假集训2K - Hero(英雄)
这也属于一个贪心题.关键是排序的依据. 这题排序的依据是敌人的伤害/血量(DPS/HP),不难证明,当这个比值相同时,不论先解决谁效果是相同的.思路大部分在注释里. 题目大意: 假设你的血量无限,但是 ...
- bzoj 1191: [HNOI2006]超级英雄Hero
1191: [HNOI2006]超级英雄Hero Time Limit: 10 Sec Memory Limit: 162 MB 二分图匹配... Description 现在电视台有一种节目叫做超 ...
- HDU 4901 The Romantic Hero
The Romantic Hero Time Limit: 3000MS Memory Limit: 131072KB 64bit IO Format: %I64d & %I64u D ...
- HDU4901 The Romantic Hero 计数DP
2014多校4的1005 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4901 The Romantic Hero Time Limit: 6000/30 ...
- HDU 4310 Hero (贪心算法)
A - Hero Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Sta ...
- BZOJ 1191: [HNOI2006]超级英雄Hero 二分匹配
1191: [HNOI2006]超级英雄Hero Description 现在电视台有一种节目叫做超级英雄,大概的流程就是每位选手到台上回答主持人的几个问题,然后根据回答问题的多少获得不同数目的奖品或 ...
随机推荐
- 关于Android使用Instrumentation做功能测试的时候遇到的一个问题
最近在看测试方面的东西,看到官网上有一个使用Instrumentation做功能测试的例子,自己敲了敲,但是在自己的手机上就是测不过. 经过调试,我发现是我手机上的输入法把输入事件拦截了,需要多输入一 ...
- 【bzoj1056】排名系统
1056: [HAOI2008]排名系统 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2195 Solved: 623[Submit][Statu ...
- 场景中,并没有灯源的存在,但是cube却会有灯光照射的反应,这就是Light Probe Group的作用。
http://blog.csdn.net/qq617119142/article/details/41674755
- 十三.sorted
排序算法 排序也是在程序中经常用到的算法.无论使用冒泡排序还是快速排序,排序的核心是比较两个元素的大小.如果是数字,我们可以直接比较,但如果是字符串或者两个dict呢?直接比较数学上的大小是没有意义的 ...
- win7 下安装mysql 整理
1.去官网下载mysql-5.6.13-winx64.zip包.地址: http://dev.mysql.com/downloads/mysql/5.6.html 2,把安装包解压到自己指定的目录,我 ...
- 面试题:TCP协议三次握手
一.首先了解TCP报文格式 其中必须了解的字段有: 1.源端口与目的端口:16位,标识出发送端与接收端的端口号. 2.序号:32位,也叫顺序号.seg序号,本报文段所发送的数据的第一个字节的序号,用来 ...
- Linux查看内存,负载状态
Linux查看内存,负载状态 查看内存使用情况 www.ahlinux.com cat /proc/meminfo MemTotal: 16332644 kB MemFree: ...
- [GO]new函数的使用
new函数的作用其实就是动态分配一个空间,我们只需要进行使用,不需要考虑它的内存释放的它的生命周期 package main import "fmt" func main() { ...
- App性能测试工具使用说明-MobilePerformance
一. 环境搭建 安装Android SDK 1.6或者1.7版本均可,建议1.7,环境变量的配置,Java SDK的安装很简单,不赘述了. 安装SDK 1.安装Android SDK: 2.安装完毕后 ...
- javascript总结16:数组array12
1 Array 对象 作用:Array 对象用于在变量中存储多个值. 1.1 数组定义 var ary = new Array();//通过创建对象的方式创建数组 var ary1 = [];// 直 ...