AtCoder Regular Contest 178
C
Sum of Abs 2
AtCoder
⌀ 1990
原题
← BD →
翻译中…

Problem Statement

翻译中…

You are given positive integers $N$ and $L$, and a sequence of positive integers $A = (A_{1}, A_{2}, \dots , A_{N})$ of length $N$.

翻译中…

For each $i = 1, 2, \dots , N$, answer the following question:

翻译中…

Determine if there exists a sequence of $L$ non-negative integers $B = (B_{1}, B_{2}, \dots, B_{L})$ such that $\displaystyle \sum_{j = 1} ^ {L - 1} \sum_{k = j + 1} ^ {L} |B_{j} - B_{k}| = A_{i}$. If it exists, find the minimum value of $\max(B)$ for such a sequence $B$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2 \times 10^{5}$
  • $2 \leq L \leq 2 \times 10^{5}$
  • $1 \leq A_{i} \leq 2 \times 10^{5}$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N L
A_{1} A_{2} \cdots A_{N}

翻译中…

Output

翻译中…

Print $N$ lines. The $k$-th line should contain -1 if no sequence $B$ satisfies the condition for $i=k$; otherwise, it should contain the minimum value of $\max(B)$ for such a sequence $B$.

翻译中…

样例

Input #1
2 4
10 5
Output #1
3
-1
For $A_{1} = 10$, if we take $B = (1, 0, 2, 3)$, then $\displaystyle \sum_{j = 1} ^ {L - 1} \sum_{k = j + 1} ^ {L} |B_{j} - B_{k}| = 10$, where $\max(B) = 3$. No non-negative integer sequence $B$ satisfies the condition with $\max(B) < 3$, so print $3$ in the first line. For $A_{2} = 5$, there is no non-negative integer sequence $B$ that satisfies the condition, so print `-1` in the second line.
Input #2
6 8
167 924 167167 167924 116677 154308
Output #2
11
58
10448
10496
7293
9645
题目信息
题号
arc178_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。