QOJ.ac

QOJ

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

#836. モンスターの農場

Statistics

$n$ 匹のモンスターがおり、$i$ 番目のモンスターの初期体力は $h_i$ です。 HP が $0$ より大きいモンスターを「生存している」と呼びます。 あなたの攻撃力は $a$ であり、対戦相手の攻撃力は $b$ です。 少なくとも 1 匹のモンスターが生存している限り、あなたと対戦相手は交互にモンスターと戦います(あなたが先攻です)。

あなたは非常に賢いため、自分のターンには生存している任意のモンスターを攻撃するか、何もしないかを選択できます。モンスター $i$ を攻撃することを選択した場合、そのモンスターの体力 $h_i$ はちょうど $a$ 減少します。 あなたの攻撃の後、そのモンスターが死亡(生存していない状態)した場合、あなたは勝利ポイントを 1 点獲得します。

一方、対戦相手はそれほど賢くありません。対戦相手のターンには、生存しているモンスターのうち最もインデックスが小さいものを見つけ、それを攻撃します(つまり、$h_i > 0$ を満たす最小の $i$ を見つけ、$h_i$ をちょうど $b$ 減少させます)。

あなたが獲得できる勝利ポイントの最大値はいくつでしょうか。

入力

入力は以下の形式で与えられます。

$n$ $a$ $b$ $h_1$ $h_2$ $\dots$ $h_n$

  • $1 \le n \le 300\,000$
  • $1 \le a, b \le 10^9$
  • $1 \le h_i \le 10^9$

出力

あなたが獲得できる勝利ポイントの最大値を 1 つの整数で出力してください。

入出力例

入力 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

注記

最初の例では、あなたの最初のターンに 3 番目のモンスターを倒し、2 回目のターンに 2 番目のモンスターを倒すことができます。

2 番目の例では、最も左のモンスターの $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.