Codeforces Round 620 (Div. 2)
F1
Animal Observation (easy version)
Codeforces
2300
原题
← EF2 →
翻译中…

The only difference between easy and hard versions is the constraint on $k$.

翻译中…

Gildong loves observing animals, so he bought two cameras to take videos of wild animals in a forest. The color of one camera is red, and the other one's color is blue.

翻译中…

Gildong is going to take videos for $n$ days, starting from day $1$ to day $n$. The forest can be divided into $m$ areas, numbered from $1$ to $m$. He'll use the cameras in the following way:

翻译中…
  • On every odd day ($1$-st, $3$-rd, $5$-th, ...), bring the red camera to the forest and record a video for $2$ days.
  • On every even day ($2$-nd, $4$-th, $6$-th, ...), bring the blue camera to the forest and record a video for $2$ days.
  • If he starts recording on the $n$-th day with one of the cameras, the camera records for only one day.
翻译中…

Each camera can observe $k$ consecutive areas of the forest. For example, if $m=5$ and $k=3$, he can put a camera to observe one of these three ranges of areas for two days: $[1,3]$, $[2,4]$, and $[3,5]$.

翻译中…

Gildong got information about how many animals will be seen in each area each day. Since he would like to observe as many animals as possible, he wants you to find the best way to place the two cameras for $n$ days. Note that if the two cameras are observing the same area on the same day, the animals observed in that area are counted only once.

翻译中…

Input

翻译中…

The first line contains three integers $n$, $m$, and $k$ ($1 \le n \le 50$, $1 \le m \le 2 \cdot 10^4$, $1 \le k \le min(m,20)$) – the number of days Gildong is going to record, the number of areas of the forest, and the range of the cameras, respectively.

翻译中…

Next $n$ lines contain $m$ integers each. The $j$-th integer in the $i+1$-st line is the number of animals that can be seen on the $i$-th day in the $j$-th area. Each number of animals is between $0$ and $1000$, inclusive.

翻译中…

Output

翻译中…

Print one integer – the maximum number of animals that can be observed.

翻译中…

Note

翻译中…

The optimal way to observe animals in the four examples are as follows:

翻译中…

Example 1:

翻译中…

image

翻译中…

Example 2:

翻译中…

image

翻译中…

Example 3:

翻译中…

image

翻译中…

Example 4:

翻译中…

image

翻译中…

样例

Input #1
4 5 2
0 2 1 1 0
0 0 3 1 2
1 0 4 3 1
3 3 0 0 4
Output #1
25
InputCopy OutputCopy
Input #2
3 3 1
1 2 3
4 5 6
7 8 9
Output #2
31
InputCopy OutputCopy
Input #3
3 3 2
1 2 3
4 5 6
7 8 9
Output #3
44
InputCopy OutputCopy
Input #4
3 3 3
1 2 3
4 5 6
7 8 9
Output #4
45
InputCopy OutputCopy
题目信息
题号
1304F1
时间限制
3 s
内存限制
512 MB
标签
数据结构
动态规划

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