#P7405. [JOI 2021 Final] 雪球 / Snowball
[JOI 2021 Final] 雪球 / Snowball
Description
On an infinitely long number line, there are snowballs, numbered . The -th snowball is at point . At the beginning, the entire number line is fully covered with snow. Then, over the next days, strong winds will blow. The wind strength on day is . If is positive, all snowballs move to the right by units. If is negative, all snowballs move to the left by units.
When an interval is covered with snow, a snowball’s mass increases by when it rolls over that interval, and the snow in that interval is cleared. Initially, every snowball has mass , and during these days, no new snow falls.
You want to know the mass of each snowball after these days end.
Input Format
The first line contains two integers , representing the number of snowballs and the number of days with wind.
The second line contains integers , representing the initial positions of the snowballs.
The next lines each contain one integer , representing the wind strength of each day.
Output Format
Output lines, each containing one integer, representing the mass of each snowball after the days.
4 3
-2 3 5 8
2
-4
7
5
4
2
6
1 4
1000000000000
1000000000000
-1000000000000
-1000000000000
-1000000000000
3000000000000
10 10
-56 -43 -39 -31 -22 -5 0 12 18 22
-3
0
5
-4
-2
10
-13
-1
9
6
14
8
7
9
11
10
9
8
5
10
Hint
Explanation of Sample 1
The initial positions of the snowballs are , and the initial masses are .
- After the first day, the snowballs are at positions , with masses .
- After the second day, the snowballs are at positions , with masses .
- After the third day, the snowballs are at positions , with masses .
Constraints
This problem uses bundled testdata.
- Subtask 1 (33 pts): .
- Subtask 2 (67 pts): no special restrictions.
For of the testdata, , , .
Note
Translated from The 20th Japanese Olympiad in Informatics Final Round B English translation Snowball.
Translated by ChatGPT 5
京公网安备 11011102002149号