大和証券プログラミングコンテスト2024(AtCoder Beginner Contest 383)
G
Bar Cover
AtCoder
⌀ 3026
原题
翻译中…

Problem Statement

翻译中…

You have a row of $N$ cells. The $i$-th cell from the left contains an integer $A_i$.

翻译中…

You also have $\lfloor \frac{N}{K} \rfloor$ tiles, each of which covers $K$ consecutive cells.

翻译中…

For each $i = 1, \ldots, \lfloor \frac{N}{K} \rfloor$, solve the following problem:

翻译中…
  • When placing exactly $i$ tiles without overlap, find the maximum possible sum of the numbers in the covered cells.
翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq K \leq \min(5,N)$
  • $-10^9 \leq A_i \leq 10^9$
  • All input values are integers.
翻译中…

Input

翻译中…

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

翻译中…

N K
A_1 \ldots A_N

翻译中…

Output

翻译中…

Print the answers for $i = 1, \ldots, \lfloor \frac{N}{K} \rfloor$ separated by spaces in one line.

翻译中…

样例

Input #1
6 2
-5 3 4 -1 6 -2
Output #1
7 12 5
For $i=1$, if you cover the 2nd and 3rd cells with one tile, the sum of the numbers in the covered cells is $7$. For $i=2$, if you cover the 2nd and 3rd cells with one tile and the 4th and 5th cells with another tile, the sum of the numbers in the covered cells is $12$.
Input #2
20 4
-5 3 4 -1 6 -2 13 -1 13 7 6 -12 3 -5 12 -6 -3 10 -15 -5
Output #2
32 45 57 52 22
题目信息
题号
abc383_g
时间限制
3 s
内存限制
1024 MB

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