#abc314g. G - Amulets
G - Amulets
Score : points
问题描述
在一个洞穴中有 只怪兽:怪兽1、怪兽2,……,怪兽。每只怪兽都有一个正整数的攻击力和一个用1到之间的整数表示的类型。具体来说,对于,怪兽的攻击力和类型分别为和。
高桥将以生命值为并携带一些从个护符中挑选出的护符(护符1、护符2,……,护符)进入这个洞穴冒险。
在冒险过程中,高桥按照以下步骤依次对进行操作(只要他的生命值不降至0或以下)。
- 如果高桥没有携带护符,则怪兽会攻击他,使他的生命值减少。
- 然后,
- 如果他的生命值大于0,则击败怪兽;
- 否则,他会在未击败怪兽的情况下死亡,并结束冒险。
对于每个独立求解以下问题。
当从个护符中选择个护符携带进入冒险时,高桥最多能击败多少只怪兽?
约束条件保证了对于,至少存在一只类型为的怪兽。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are monsters in a cave: monster , monster , , monster . Each monster has a positive integer attack power and a type represented by an integer between and , inclusive. Specifically, for , the attack power and type of monster are and , respectively.
Takahashi will go on an adventure in this cave with a health of and some of the amulets: amulet , amulet , , amulet .
In the adventure, Takahashi performs the following steps for in this order (as long as his health does not drop to or below).
- If Takahashi has not brought amulet with him, monster will attack him and decrease his health by .
- Then,
- if his health is greater than , he defeats monster ;
- otherwise, he dies without defeating monster and ends his adventure.
Solve the following problem for each independently.
Find the maximum number of monsters that Takahashi can defeat when choosing of the amulets to bring on the adventure.
The constraints guarantee that there is at least one monster of type for each .
Constraints
- For each , there is such that .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
For each , let be the maximum number of monsters that Takahashi can defeat when . Print separated by spaces in the following format:
Sample Input 1
7 3 7
3 2
1 1
4 2
1 2
5 1
9 3
2 3
Sample Output 1
2 5 7 7
Consider the case . Here, Takahashi can bring amulet to defeat the maximum possible number of monsters, which is . The adventure proceeds as follows.
- For , he avoids the attack of monster since he has amulet . Then, he defeats monster .
- For , he takes the attack of monster and his health becomes since he does not have amulet . Then, he defeats monster .
- For , he avoids the attack of monster since he has amulet . Then, he defeats monster .
- For , he avoids the attack of monster since he has amulet . Then, he defeats monster .
- For , he takes the attack of monster and his health becomes since he does not have amulet . Then, he defeats monster .
- For , he takes the attack of monster and his health becomes since he does not have amulet . Then, he dies without defeating monster and ends his adventure.
Similarly, when , he can defeat monsters; when , he can defeat all monsters by bringing amulets and ; when , he can defeat all monsters by bringing amulets , , and .
Sample Input 2
15 5 400
29 5
27 4
79 1
27 2
30 3
4 1
89 2
88 3
75 5
3 1
39 4
12 1
62 4
38 2
49 1
Sample Output 2
8 12 15 15 15 15
update @ 2024/3/10 08:59:43