FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼)
FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼)
Time Limit: 1000MS Memory Limit: 257792K
|
【Description】 |
【题目描述】 |
|
Fat Brother is a Great warrior(战士) and he has a powerful weapons named “Gorehowl”. Firstly it can cause 7 damage points to the other side, but it will decrease 1 damage points after one attack. One day, Fat Brother meet N monsters, but he only take his “Gorehowl”. Each monster has health points. When Fat Brother attacked a monster, the monster’s health points will decrease damage points of “Gorehowl”. If a monster’s health points less than or equal to zero, it die. Fat Brother must kill all monsters or he can’t get away from here. If he can kill all monster, he want to know least of times he should attack. If he can’t, he will choose go die. |
胖哥是一位信仰战,并且他拥有把名叫“血吼”的强力武器。一开始可以对一个目标造成7点伤害,然后每次攻击后减少1点攻击力。 一天,胖哥偶遇N只随从,但是他只带了“血吼”。 每只随从都有一定的生命值。当胖哥攻击一只随从后,这只随从的生命值会被减去“血吼”的攻击力。如果一只随从的生命值小等于0,即死亡。胖哥解决所有随从否则无法脱身。如果胖哥能够清场,他想知道最少的攻击次数。如果不行,他选择死亡。 |
|
【Input】 |
【输入】 |
|
There are multiple test cases. The first line of input contains an integer T (T <= 50) indicating the number of test cases. For each test case: The first line contains one integer N (1 <= N <= 100000) means number of monsters. The next line contains N number Hi (1<= Hi <= 10) means monster’s health points. |
多组测试用例。 第一行是一个整数T(T <= 50)表示测试用例的数量。对于每个测试用例: 第一行是一个整数N(1 <= N <= 100000)表示随从的数量。 下一行有N个数Hi(1<= Hi <= 10),表示随从的生命值。 |
|
【Output】 |
【输出】 |
|
If Fat Brother can kill all monsters, output a number means least of times Fat Brother should attack. Otherwise output “Fat Brother choose go die” |
如果胖哥能够消灭所有随从,输出他最少的攻击次数,否则输出“Fat Brother choose go die” |
|
【Sample Input - 输入样例】 |
【Sample Output - 输出样例】 |
|
3 2 12 6 1 28 1 29 |
3 7 Fat Brother choose go die |
|
【Hint】 |
【提示】 |
|
First case, First attack first monster and it’s health points decrease to 5. Second attack second monster and it’s health points decrease to 0, it will die. Third attack first monster and it’s health points decrease to 0, it will die. All monster die! Second case, attack first monster 7 times, and sum of damage points is 7 + 6 + 5 + 4 + 3 + 2 + 1 = 28, kill all monster. Third case, Fat Brother can’t kill first monster, so he will choose go die. The test sample just explain problem, you can think the really data is accord with the title's description |
第一个样例, 第一次攻击第一只随从使其生命值归5。第二次攻击第二只随从使其生命值归0,把它消灭。第三次攻击第一只随从使其生命值归0,把它消灭。所有随从阵亡。 第二个样例, 攻击第一只随从7次,攻击力的和为7 + 6 + 5 + 4 + 3 + 2 + 1 = 28,所有随从阵亡。 第三个样例, 胖哥无法解决第一只随从,因此他选择死亡。 测试用例仅供说明,你可认为实际数据都符合题目描述。 |
【题解】
实际需要处理的数据量不大,暴力搜索应该没问题,不过出于看(qiang)得(po)爽(zheng),就用贪心了。
一共只能攻击7次,分别是 1 2 3 4 5 6 7
那么先在读取的时候剪个枝,N > 7或 Hid的和 > 28,直接选择死亡。
然后我们把血吼每次的攻击力离散化,变成你每次都能造成1~7点伤害,但是造成的伤害不能重复。
为了尽快砍死随从,可用攻击力 = 当前随从生命值 的情况最优先使用。
其次若没有恰好相等的情况,为了减少浪费,则用剩余的最高可用攻击力砍生命值最高的随从。
【代码 C++】
#include<cstdio>
#include <cstring>
#include <queue>
std::priority_queue<int, std::vector<int> > data, wait;
bool us[];
int n;
bool read(){
scanf("%d", &n);
int i, j, s;
if (n > ){
for (i = ; i < n; ++i) scanf("%d", &j);
return ;
}
while (!data.empty()) data.pop();
memset(us, , sizeof(us));
for (i = s = ; i < n; ++i){
scanf("%d", &j); s += j;
if (j <= && !us[j]) ++us[j];
else data.push(j);
}
if (s>) return ;
while (!wait.empty()) wait.pop();
for (i = ; i <= ; ++i) if (!us[i]) wait.push(i);
return ;
}
int main(){
int t, i, j, d, w;
while (~scanf("%d", &t)){
while (t--){
if (read()){
while (!wait.empty() && !data.empty()){
w = wait.top(); wait.pop(); ++us[w];
d = data.top(); data.pop(); d -= w;
if (d > ){
if (d <= && !us[d]) ++us[d];
else data.push(d);
}
while (!wait.empty() && us[wait.top()]) wait.pop();
}
if (data.empty()){
for (i = j = ; i <= ; ++i) if (us[i]) ++j;
printf("%d\n", j);
}
else puts("Fat Brother choose go die");
}
else puts("Fat Brother choose go die");
}
}
return ;
}
FJNU 1156 Fat Brother’s Gorehowl(胖哥的血吼)的更多相关文章
- FJNU 1154 Fat Brother And His Love(胖哥与女神)
FJNU 1154 Fat Brother And His Love(胖哥与女神) Time Limit: 2000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1153 Fat Brother And XOR(胖哥与异或)
FJNU 1153 Fat Brother And XOR(胖哥与异或) Time Limit: 1000MS Memory Limit: 257792K [Description] [题目描述] ...
- FJNU 1155 Fat Brother’s prediction(胖哥的预言)
FJNU 1155 Fat Brother’s prediction(胖哥的预言) Time Limit: 1000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1152 Fat Brother And Integer(胖哥与整数)
FJNU 1152 Fat Brother And Integer(胖哥与整数) Time Limit: 1000MS Memory Limit: 257792K [Description] [题 ...
- FJNU 1151 Fat Brother And Geometry(胖哥与几何)
FJNU 1151 Fat Brother And Geometry(胖哥与几何) Time Limit: 1000MS Memory Limit: 257792K [Description] [ ...
- FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术)
FJNU 1157 Fat Brother’s ruozhi magic(胖哥的弱智术) Time Limit: 1000MS Memory Limit: 257792K [Description ...
- FJNU 1159 Fat Brother’s new way(胖哥的新姿势)
FJNU 1159 Fat Brother’s new way(胖哥的新姿势) Time Limit: 1000MS Memory Limit: 257792K [Description] [题目 ...
- HDU 4637 Rain on your Fat brother 线段与半圆和线段交 简单题
题意: 应该不难读懂. 做法: 我们可以把雨滴看做静止不动,然后maze(这题的那个人)就是往左上方运动就可以了,计算出maze能跑到的最远的点,然后就是求起点和终点所构成的线段与每个雨滴交的时间,注 ...
- 大数据的胖哥的方式(9)- 金融业数据仓库的逻辑模型FS-LDM
介绍: 大数据是不是海市蜃楼,来自小橡子只是意淫奥克斯,大数据的发展,而且要从头开始,基于大数据建设国家.项目-level数据中心行业将越来越多,大数据仅供技术,而非溶液,临数据组织模式,数据逻辑模式 ...
随机推荐
- 不允许调用库函数,也不允许使用任何全局或局部变量编写strlen函数
不允许调用库函数,也不允许使用任何全局或局部变量编写strlen函数. 这是一道面试题,可以使用递归的方式解答,答案如下: #include <stdio.h> int mylen(cha ...
- linux配置java环境变量(详细)【转】
转自:http://www.cnblogs.com/samcn/archive/2011/03/16/1986248.html 一. 解压安装jdk 在shell终端下进入jdk-6u14-linux ...
- Mysql密码恢复
由于种种原因,Mysql root用户的密码可能被恶意篡改,这个时候就需要对Mysql进行密码恢复了.大致步骤如下: 1.修改MySQL的登录设置: # vi /etc/my.cnf 在[mysqld ...
- php curl应该怎么使用呢
原php默认并不进行此项功能的扩展,但还是有的,只是没有让它生效罢了.打开PHP安装目录,搜索以下三个文件 ssleay32.dll.libeay32.dll和 php_ curl .dll,一一拷贝 ...
- 做一个MVC4的项目时留下的经验--增加IPrange
/* CR#1796870 modify by v-yangwu, add a js file to control the page controls. */ $(document).ready(f ...
- 错误: 找不到或无法加载主类 Files\apache-activemq-5.10.0\bin\..\conf\login.config
在启动activemq的时候出现错误:“错误: 找不到或无法加载主类 Files\apache-activemq-5.10.0\bin\..\conf\login.config”,之前用activem ...
- 记得ajax中要带上AntiForgeryToken防止CSRF攻击
经常看到在项目中ajax post数据到服务器不加防伪标记,造成CSRF攻击 在Asp.net Mvc里加入防伪标记很简单在表单中加入Html.AntiForgeryToken()即可. Html.A ...
- java面试每日一题9
题目:判断一个数是否是2的方次幂 public class Power { public static void main(String [] args) throws NumberFormatExc ...
- [HTML]DIV+CSS 文字垂直居中
在说到这个问题的时候,也许有人会问CSS中不是有vertical-align属性来设置垂直居中的吗?即使是某些浏览器不支持我只需做少许的CSS Hack技术就可以啊!所以在这里我还要啰嗦两句,CSS中 ...
- extjs 中动态给gridpanel 复选框赋值
最近在搞extjs时需要动态根据数据给gridpanel的复选框赋值 网上看了很多 ,多不行,最后找到一个好使的方法 如下: RBACformPanel.getSelectionModel().sel ...