QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#836. 怪獸農場

Statistics

有 $n$ 隻怪物,第 $i$ 隻怪物初始時有 $h_i$ 點生命值。 若怪物的生命值嚴格大於零,我們稱該怪物為「存活」。 你的攻擊力為 $a$,對手的攻擊力為 $b$。 只要還有怪物存活,你和對手就會輪流攻擊怪物(由你先開始)。 你非常聰明,因此在你的回合中,你可以選擇攻擊任何存活的怪物,或者什麼都不做。如果你選擇攻擊第 $i$ 隻怪物,該怪物的生命值 $h_i$ 將會減少恰好 $a$ 點。 在你的攻擊之後,如果該怪物死亡(不再存活),你將獲得一點勝利點數。 另一方面,你的對手並不聰明。在他的回合中,他會找到索引最小的存活怪物並攻擊它(即找到最小的 $i$ 使得 $h_i > 0$,並將 $h_i$ 減少恰好 $b$ 點)。 請問你最多能獲得多少勝利點數?

輸入格式

第一行包含三個整數 $n, a, b$ ($1 \le n \le 300\,000, 1 \le a, b \le 10^9$):分別為怪物的數量、你的攻擊力以及對手的攻擊力。 第二行包含 $n$ 個整數 $h_1, h_2, \dots, h_n$ ($1 \le h_i \le 10^9$):怪物的生命值。

輸出格式

輸出一個整數:你所能獲得的最大勝利點數。

範例

範例 1

3 1 1
1 1 1

輸出 1

2

範例 2

3 1 1
2 2 2

輸出 2

3

範例 3

10 34 100
17 27 73 17 60 12 25 53 31 46

輸出 3

5

說明

在第一個範例中,在你的第一個回合,你可以殺死第三隻怪物,而在你的第二個回合,你可以殺死第二隻怪物。 在第二個範例中,你可以等待直到最左邊的怪物生命值變為 $h_i = 1$,然後親手殺死它。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.