#P14475. 大鱼吃小鱼

大鱼吃小鱼

Problem Description

Elephant is playing the Big Fish Eat Small Fish game. Initially, there are nn fish lined up in a row in order of indices 11 to nn, and each fish has a size value (a positive integer) aia_i.

A big fish can eat a small fish, but only if the size difference is large enough. There is a fixed parameter (a non-negative integer) kk.

Elephant can control one fish to eat one adjacent fish (with no other fish between them). There are two ways to eat:

  1. Eat directly: the controlled fish's size must be no smaller than the eaten fish's size, and the size difference must be at least kk. That is, a fish of size xx can eat a fish of size yy directly if and only if xykx-y\ge k.
  2. Use one tool: ignore the size difference and eat one fish.

After eating, the eaten fish disappears, and the controlled fish's size increases by the eaten fish's size. The relative order of fish positions does not change.

Elephant wants to know: for each ii, if he controls fish ii to eat all other fish, what is the minimum number of tools needed.

Input Format

Note: Due to Luogu's judging limitations, when submitting this problem on Luogu, please use standard input/output, and do not use file input/output.

The first line contains two non-negative integers n,kn, k, separated by spaces.

The second line contains nn positive integers aia_i separated by spaces, describing the initial size of each fish in order from index 11 to nn.

Output Format

Output one line with nn non-negative integers separated by spaces. The ii-th integer is the answer for each ii, i.e., the minimum number of tools needed for fish ii to eat all fish.

5 4
5 6 5 1 2

1 1 1 2 3
5 3
6 4 2 2 6
1 1 2 1 0

Hint

Constraints

For all testdata, 1n5×1061 \leq n \leq 5 \times 10^6, 0k1090 \leq k \leq 10^9, 1ai1091 \leq a_i \leq 10^9.

For 10%10\% of the testdata, n20n \leq 20.

For another 10%10\% of the testdata, n2000n \leq 2000.

For another 15%15\% of the testdata, n2×105n \leq 2 \times 10^5, k=0k = 0.

For another 15%15\% of the testdata, n2×105n \leq 2 \times 10^5, k10k \leq 10.

For another 15%15\% of the testdata, n2×105n \leq 2 \times 10^5.

Note that this problem uses bundled subtasks.

Translated by ChatGPT 5