#P7405. [JOI 2021 Final] 雪球 / Snowball

[JOI 2021 Final] 雪球 / Snowball

Description

On an infinitely long number line, there are NN snowballs, numbered 1N1 \sim N. The ii-th snowball is at point AiA_i. At the beginning, the entire number line is fully covered with snow. Then, over the next QQ days, strong winds will blow. The wind strength on day jj is WjW_j. If WjW_j is positive, all snowballs move to the right by WjW_j units. If WjW_j is negative, all snowballs move to the left by Wj-W_j units.

When an interval [a,a+1][a,a+1] is covered with snow, a snowball’s mass increases by 11 when it rolls over that interval, and the snow in that interval is cleared. Initially, every snowball has mass 00, and during these QQ days, no new snow falls.

You want to know the mass of each snowball after these QQ days end.

Input Format

The first line contains two integers N,QN, Q, representing the number of snowballs and the number of days with wind.

The second line contains NN integers AiA_i, representing the initial positions of the NN snowballs.

The next QQ lines each contain one integer WjW_j, representing the wind strength of each day.

Output Format

Output NN lines, each containing one integer, representing the mass of each snowball after the QQ 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 2,3,5,8-2, 3, 5, 8, and the initial masses are 0,0,0,00, 0, 0, 0.

  • After the first day, the snowballs are at positions 0,5,7,100, 5, 7, 10, with masses 2,2,2,22, 2, 2, 2.
  • After the second day, the snowballs are at positions 4,1,3,6-4, 1, 3, 6, with masses 4,4,2,34, 4, 2, 3.
  • After the third day, the snowballs are at positions 3,8,10,133, 8, 10, 13, with masses 5,4,2,65, 4, 2, 6.

Constraints

This problem uses bundled testdata.

  • Subtask 1 (33 pts): N,Q2000N, Q \le 2000.
  • Subtask 2 (67 pts): no special restrictions.

For 100%100\% of the testdata, 1N,Q2×1051 \le N, Q \le 2 \times 10^5, Ai,Wj1012|A_i|, |W_j| \le 10^{12}, Ai<Ai+1A_i < A_{i+1}.

Note

Translated from The 20th Japanese Olympiad in Informatics Final Round B English translation Snowball.

Translated by ChatGPT 5