#abc310h. Ex - Negative Cost
Ex - Negative Cost
Score : points
问题描述
一只拥有 点生命值的怪物出现在你面前。此时你的魔法力量为 。
你可以任意次数、任意顺序地使用 种移动招式,分别为移动 、移动 、……、移动 。
对于每个 ,在你的魔法力量至少为 时才能使用第 种移动招式。使用该招式后,你的魔法力量将减少 ,同时怪物的生命值减少 。需要注意的是,如果 为负数,则减少 的魔法力量意味着增加 的魔法力量。
找出在使怪物生命值降至 或更低之前,你最少需要使用移动招式的次数。本问题的约束条件保证了通过有限次的移动招式使用可以使怪物生命值变为 或更低(见下文)。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
A monster with health has appeared right in front of you. Your magic power is now .
You can use moves called move , move , , move , any number of times in any order.
For each , move can only be used when your magic power is at least , and its use will decrease your magic power by and the monster's health by . Here, if is negative, decreasing your magic power by means increasing it by .
Find the minimum possible number of times you use moves before the monster's health is or lower. The constraints of this problem guarantee that a finite number of uses of moves can make it or lower (see below).
Constraints
- for some .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 48
3 20
-4 2
1 5
Sample Output 1
5
From the initial state where your magic power is and the monster's health is , consider using moves as follows.
- Use move . Now, your magic power is , and the monster's health is .
- Use move . Now, your magic power is , and the monster's health is .
- Use move . Now, your magic power is , and the monster's health is .
- Use move . Now, your magic power is , and the monster's health is .
- Use move . Now, your magic power is , and the monster's health is .
Here, you use moves five times before the monster's health is not greater than , which is the minimum possible number.
Sample Input 2
20 583988303060450752
-64 273760634
-238 960719353
-114 191410838
-250 357733867
232 304621362
-286 644706927
210 37849132
-230 556412112
-142 136397527
101 380675202
-140 152300688
190 442931589
-187 940659077
-12 312523039
32 126515475
-143 979861204
105 488280613
240 664922712
290 732741849
69 541282303
Sample Output 2
595990842
update @ 2024/3/10 08:49:46