tHackerrank Fight the Monsters!Week of Code 32
来源:互联网 发布:手机淘宝5.9.0版本 编辑:程序博客网 时间:2024/06/08 05:36
B.Fight the Monsters!
题目链接
题意:有n个怪兽,每个怪兽有h[i]的血量,每次攻击力为hti,一次耗时1秒,问t秒时,最多消灭多少怪兽;
题解:水题,直接排序,怪兽从小向大计算时间,统计怪数个数;
Code:
#include<bits/stdc++.h>#define ll long longusing namespace std;int n;ll h[100005],cnt,hit,t,res=0;int main(){ scanf("%d%d%d",&n,&hit,&t); for(int i=0;i<n;++i) { scanf("%d",&h[i]); } sort(h,h+n); for(int i=0;i<n;++i) { int tt=h[i]/hit; if(h[i]%hit)++tt; res+=tt; if(res>t) { cnt=i; break; } else { cnt=i+1; } } cout << cnt << endl; return 0;}
阅读全文
0 0
- tHackerrank Fight the Monsters!Week of Code 32
- Hackerrank Week of Code 32
- Week of Code:GG
- Week Of Code 27
- Week Of Code 28
- The Week Code
- hackerrank Week of Code Target
- [HackerRank]Week Of Code 23
- The work of this week
- The work of this week
- HackerRank Week of Code -18 GG
- HackerRank——Week of Code 26
- Hackerrank——Week of Code 27
- Hackerrank——Week of Code 29
- The feeling of the first week
- Guru of the Week 条款25:auto_ptr
- Schedule of the following week(9.24~9.30)
- Guru of the Week 条款17:转型
- 双向链表和循环双向链表的一些简单操作集
- C语言学习环境搭建
- 链表面试题(十一)---求带环单链表 环的入口点
- HDU 2859 简单DP
- java开发环境搭建
- tHackerrank Fight the Monsters!Week of Code 32
- CIDEr: Consensus-based Image Description Evaluation
- RocketMQ源码解析:Filtersrv
- Codeforces--808B
- 链表面试题(十二)---判断两个都不带环的链表是否相交
- iOS开发者遇到审核失败的原因及解决办法
- jquery.form.js
- html div 水平垂直居中
- 修改nginx站点根目录总结经验