A13177 | Animal Observation (easy version)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
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.
输出格式
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:

Example 1:
Example 2:
Example 3:
Example 4:

C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted