CF1304F1.Animal Observation (easy version)

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

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 nn days, starting from day 11 to day nn . The forest can be divided into mm areas, numbered from 11 to mm . He'll use the cameras in the following way:

  • On every odd day ( 11 -st, 33 -rd, 55 -th, ...), bring the red camera to the forest and record a video for 22 days.
  • On every even day ( 22 -nd, 44 -th, 66 -th, ...), bring the blue camera to the forest and record a video for 22 days.
  • If he starts recording on the nn -th day with one of the cameras, the camera records for only one day.

Each camera can observe kk consecutive areas of the forest. For example, if m=5m=5 and k=3k=3 , he can put a camera to observe one of these three ranges of areas for two days: [1,3][1,3] , [2,4][2,4] , and [3,5][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 nn 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.

输入格式

The first line contains three integers nn , mm , and kk ( 1n501 \le n \le 50 , 1m21041 \le m \le 2 \cdot 10^4 , 1kmin(m,20)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 nn lines contain mm integers each. The jj -th integer in the i+1i+1 -st line is the number of animals that can be seen on the ii -th day in the jj -th area. Each number of animals is between 00 and 10001000 , inclusive.

输出格式

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

输入输出样例

  • 输入#1

    4 5 2
    0 2 1 1 0
    0 0 3 1 2
    1 0 4 3 1
    3 3 0 0 4

    输出#1

    25
  • 输入#2

    3 3 1
    1 2 3
    4 5 6
    7 8 9

    输出#2

    31
  • 输入#3

    3 3 2
    1 2 3
    4 5 6
    7 8 9

    输出#3

    44
  • 输入#4

    3 3 3
    1 2 3
    4 5 6
    7 8 9

    输出#4

    45

说明/提示

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

Example 1:

Example 2:

Example 3:

Example 4:

首页