問題一覧 > 通常問題

No.2662 Installing Cell Towers

レベル : / AI推定難易度 : 1250 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 23
作問者 : ymmtr(せるたわーしーぷ!) / テスター : 2bit aplysiaistp
お気に入りにしたユーザー ProblemId : 9294 / 自分の提出
問題文最終更新日: 2024-03-06 15:06:52
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original

Problem Statement

There is a sequence $A=(a_1,a_2,\dots,a_N)$ of length $N$. Initially, all elements of this sequence are $0$.
Also, two sequences of length $M$ are given as $P=(p_1,p_2,\dots,p_M),Q=(q_1,q_2,\dots,q_M)$.

Now, for each integer $i=1,2,\dots,M$, perform the following operation:

  • For each integer $j=1,2,\dots,N$, let $d=|p_i-j|$, and add $max(0,q_i-d)$ to $a_j$.
Here, for real numbers $s,t$, $max(s,t)$ is defined as the value among $s$ and $t$ that is not the smaller one.
Find the value of each element of the sequence $A$ after all these operations are finished.

Input

$N\ M$
$p_1\ q_1$
$p_2\ q_2$
$\vdots$
$p_M\ q_M$

The input satisfies all of the following constraints.

  • $1\le N \le 10^5$
  • $1\le M \le 10^5$
  • $1\le p_i \le N$
  • $1\le q_i \le 10^9$
  • All inputs are integers.

Output

Output $a_1,a_2,\dots,a_N$ in order from left to right, separated by spaces.
Print a newline at the end.

Sample

Sample 1
Input
8 1
4 2
Output
0 0 1 2 1 0 0 0

In this case, only the operation for $i=1$ is performed. Here, $q_i=q_1=2$.
For $j=1,2,6,7,8$, we have $d=|p_i-j|=|4-j|\ge 2$ in every case, so $max(0,q_i-d)=max(0,2-d)=0$ is added to $a_j$.
For $j=3,5$, we have $d=1$ in both cases, so $max(0,q_i-d)=max(0,2-1)=1$ is added to $a_j$.
For $j=4$, we have $d=0$, so $max(0,q_i-d)=max(0,2-0)=2$ is added to $a_j$.
From the above, the final sequence $A$ is as shown above.

Sample 2
Input
8 1
2 3
Output
2 3 2 1 0 0 0 0

Perform the operations in the same way as in Sample 1.

Sample 3
Input
9 2
1 100
9 100
Output
192 192 192 192 192 192 192 192 192

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。