主页
题目
状态
排名
OI排名
统计
题解
请登录
常用链接
AOJ考试平台
老赵的Gitee代码
编译原理模拟考试平台
Java技术手册
FCC网站
菜鸟网
在线工具箱
字节豆包GPT
代码可视化
力扣网
牛客网
洛谷
杭电OJ
CodeForce
隐藏编译器
Problem A: 花生采摘
上一题
正确率: $71.43\%$
下一题
Time Limit
$1$ 秒/Second(s)
Memory Limit
$512$ 兆字节/Megabyte(s)
提交总数
$7$
正确数量
$5$
"
裁判形式
标准裁判/Standard Judge
我的状态
尚未尝试
难度
分类标签
图论
×
为本题添加算法分类(请不要超过5个)
当前分类(单击移除):
图论
单击选择分类:
Description
<p><style type="text/css">p { margin-bottom: 0.21cm; }</style> <p style="margin-bottom: 0cm;">鲁宾逊先生有一只宠物猴,名叫多多。这天,他们两个正沿着乡间小路散步,突然发现路边的告示牌上贴着一张小小的纸条:“欢迎免费品尝我种的花生!——熊字”。</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">鲁宾逊先生和多多都很开心,因为花生正是他们的最爱。在告示牌背后,路边真的有一块花生田,花生植株整齐地排列成矩形网格(如图<font face="DejaVu Serif, serif">1</font>)。有经验的多多一眼就能看出,每棵花生植株下的花生有多少。为了训练多多的算术,鲁宾逊先生说:“你先找出花生最多的植株,去采摘它的花生;然后再找出剩下的植株里花生最多的,去采摘它的花生;依此类推,不过你一定要在我限定的时间内回到路边。”</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">我们假定多多在每个单位时间内,可以做下列四件事情中的一件:</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">1) </font>从路边跳到最靠近路边(即第一行)的某棵花生植株;</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">2) </font>从一棵植株跳到前后左右与之相邻的另一棵植株;</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">3) </font>采摘一棵植株下的花生;</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;"><font face="DejaVu Serif, serif">4) </font>从最靠近路边(即第一行)的某棵花生植株跳回路边。</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">现在给定一块花生田的大小和花生的分布,请问在限定时间内,多多最多可以采到多少个花生?注意可能只有部分植株下面长有花生,假设这些植株下的花生个数各不相同。</p> <p style="margin-bottom: 0cm;"></p> <p style="margin-bottom: 0cm;">例如在图<font face="DejaVu Serif, serif">2</font>所示的花生田里,只有位于<font face="DejaVu Serif, serif">(2, 5), (3, 7), (4, 2), (5, 4)</font>的植株下长有花生,个数分别为<font face="DejaVu Serif, serif">13, 7, 15, 9</font>。沿着图示的路线,多多在<font face="DejaVu Serif, serif">21</font>个单位时间内,最多可以采到<font face="DejaVu Serif, serif">37</font>个花生。</p> <p style="margin-bottom: 0cm;"></p> </p>
Input
<p><style type="text/css">p { margin-bottom: 0.21cm; }</style> <p style="margin-bottom: 0cm;">输入文件<font face="DejaVu Serif, serif">peanuts.in</font>的第一行包括三个整数,<font face="DejaVu Serif, serif">M, N</font>和<font face="DejaVu Serif, serif">K</font>,用空格隔开;表示花生田的大小为<font face="DejaVu Serif, serif">M * N</font>(<font face="DejaVu Serif, serif">1 <= M, N <= 20</font>),多多采花生的限定时间为<font face="DejaVu Serif, serif">K</font>(<font face="DejaVu Serif, serif">0 <= K <= 1000</font>)个单位时间。接下来的<font face="DejaVu Serif, serif">M</font>行,每行包括<font face="DejaVu Serif, serif">N</font>个非负整数,也用空格隔开;第<font face="DejaVu Serif, serif">i + 1</font>行的第<font face="DejaVu Serif, serif">j</font>个整数<font face="DejaVu Serif, serif">Pij</font>(<font face="DejaVu Serif, serif">0 <= Pij <= 500</font>)表示花生田里植株<font face="DejaVu Serif, serif">(i, j)</font>下花生的数目,<font face="DejaVu Serif, serif">0</font>表示该植株下没有花生。</p> <p style="margin-bottom: 0cm;"></p> </p>
Output
<p><style type="text/css">p { margin-bottom: 0.21cm; }</style> <p style="margin-bottom: 0cm;">输出文件<font face="DejaVu Serif, serif">peanuts.out</font>包括一行,这一行只包含一个整数,即在限定时间内,多多最多可以采到花生的个数。</p> </p>
Sample Input
复制
6 7 21 0 0 0 0 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0 0 7 0 15 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0
Sample Output
复制
37
AOJ
Please Login