loj#P3469. 「JOI 2021 Final」雪球
「JOI 2021 Final」雪球
Description
The JOI plain is a wide plain spreading from west to east. We can consider the JOI plain as a number line. A spot on the JOI plain is denoted by a coordinate. The positive direction of the number line corresponds to the east direction. Now winter comes in the JOI plain. There are snowballs on it, numbered from to from the west to the east. In the beginning, the coordinate of the snowball () is an integer .
Strong wind blows in the JOI plain in winter. You have observation data of wind for days. On the -th day (), the wind is described by an integer . If is negative, then the wind blows to the west direction. If is not negative, then the wind blows to the east direction. The strength of the wind is .
When wind blows, a snowball is moved to the same direction as the wind, and its length of move is equal to the strength of the wind. In other words, if there is a snowball in the coordinate in the beginning of the -th day (), then the snowball is moved from the coordinate to the coordinate . At the end of the j-th day, the coordinate of the snowball becomes . Note that, in each day, the snowballs are moved at the same time, and their speeds are the same.
Initially, the JOI plain is covered with snow. If a snowball is moved on an interval covered with snow, then the snowball accumulates the snow, the weight of the snowball is increased, and the snow on the interval disappears. In other words, for an integer , assume that the interval from to is covered with snow. If a snowball is moved on this interval, then the weight of the snowball is increased by , and the snow on the interval from to disappears. However, if a snowball is moved on an interval without snow, the weight of the snowball remains the same.
Initially, the weight of every snowball is . It did not snow on the days of observation data.
You want to know the weight of each snowball at the end of the -th day.
Write a program which, given the initial position of each snowball and observation data of wind for days, calculates the weight of each snowball at the end of the -th day.
Input
Read the following data from the standard input. Given values are all integers.
Output
Write lines to the standard output. The -th line () should contain the weight of the snowball at the end of the -th day.
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
Constraints
- .
- .
- ().
- ().
- ().
Subtasks
- ( points) , .
- ( points) No additional constraints.