luogu#P5026. Lycanthropy
Lycanthropy
Background
The little square saw with its own eyes that its former friend was swept into a dark abyss, yet it was powerless to stop it……
Now its friend has attacked it, so the little square has no choice but to fight back.
Problem Description
We treat the lake on the mountaintop as a straight line of length . At the beginning, the water depth everywhere is on the baseline, and we regard the water depth at this time as '0'.
Next, in an instant, the little square’s "friends" jump up and dive into the water, causing the water level at the entry point to drop and the water level far away from the entry point to rise. Note that two "friends" may enter the water at the same position.
Each friend of the little square has a volume value . When a friend with volume jumps into the water, let the entry point be . This will cause the water levels from to to decrease by respectively.
Similarly, the water levels from to will decrease by respectively.
Correspondingly, the water level at does not change. The water levels from to increase by respectively, and the water levels from to increase by respectively.
Similarly, the water level at does not change. The water levels from to increase by respectively, and the water levels from to increase by respectively.
Now the little square wants to cross this lake. It wants to know the water level at each position of the lake after these "friends" have jumped into the water. Can you help it?
Input Format
The first line contains two integers , , representing the number of "friends" and the width of the lake.
The next lines each contain two integers , representing the volume and the entry point of the -th friend.
Output Format
Output one line with integers. The -th integer represents the water depth at position .
1 10
1 5
0 0 1 0 -1 0 1 0 0 0
2 10
2 6
3 1
-2 0 0 0 0 0 2 2 2 2
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, .
Translated by ChatGPT 5