#P14475. 大鱼吃小鱼
大鱼吃小鱼
Problem Description
Elephant is playing the Big Fish Eat Small Fish game. Initially, there are fish lined up in a row in order of indices to , and each fish has a size value (a positive integer) .
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) .
Elephant can control one fish to eat one adjacent fish (with no other fish between them). There are two ways to eat:
- 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 . That is, a fish of size can eat a fish of size directly if and only if .
- 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 , if he controls fish 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 , separated by spaces.
The second line contains positive integers separated by spaces, describing the initial size of each fish in order from index to .
Output Format
Output one line with non-negative integers separated by spaces. The -th integer is the answer for each , i.e., the minimum number of tools needed for fish 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, , , .
For of the testdata, .
For another of the testdata, .
For another of the testdata, , .
For another of the testdata, , .
For another of the testdata, .
Note that this problem uses bundled subtasks.
Translated by ChatGPT 5