Educational Codeforces Round 125 (Rated for Div. 2)
比赛链接
Educational Codeforces Round 125 (Rated for Div. 2)
D. For Gamers. By Gamers.
Monocarp is playing a strategy game. In the game, he recruits a squad to fight monsters. Before each battle, Monocarp has coins to spend on his squad.
Before each battle starts, his squad is empty. Monocarp chooses one type of units and recruits no more units of that type than he can recruit with coins.
There are types of units. Every unit type has three parameters:
- - the cost of recruiting one unit of the -th type;
- - the damage that one unit of the -th type deals in a second;
- - the amount of health of one unit of the -th type.
Monocarp has to face monsters. Every monster has two parameters: - - the damage that the -th monster deals in a second;
- - the amount of health the -th monster has.
Monocarp has to fight only the -th monster during the -th battle. He wants all his recruited units to stay alive. Both Monocarp's squad and the monster attack continuously (not once per second) and at the same time. Thus, Monocarp wins the battle if and only if his squad kills the monster strictly faster than the monster kills one of his units. The time is compared with no rounding.
For each monster, Monocarp wants to know the minimum amount of coins he has to spend to kill that monster. If this amount is greater than , then report that it's impossible to kill that monster.
Input
The first line contains two integers and - the number of types of units and the amount of coins Monocarp has before each battle.
The -th of the next lines contains three integers and .
The next line contains a single integer - the number of monsters that Monocarp has to face.
The -th of the next lines contains two integers and .
Output
Print integers. For each monster, print the minimum amount of coins Monocarp has to spend to kill that monster. If this amount is greater than , then print .
解题思路
二分,思维
设一个单元的血量为 ,攻击为 ,用了 个单位,一个怪兽的血量为 ,攻击为 ,则 ,即 ,由于总花费 较小,可以预处理对于每个花费 可以造成的最大的 ,然后再二分答案即可
- 时间复杂度:
代码
__EOF__

本文链接:https://www.cnblogs.com/zyyun/p/16044056.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!