A10856 | Maximum path
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given a rectangular table $3×n$ . Each cell contains an integer. You can move from one cell to another if they share a side.
Find such path from the upper left cell to the bottom right cell of the table that doesn't visit any of the cells twice, and the sum of numbers written in the cells of this path is maximum possible.
Find such path from the upper left cell to the bottom right cell of the table that doesn't visit any of the cells twice, and the sum of numbers written in the cells of this path is maximum possible.
输入格式
The first line contains an integer $n$ ( $1<=n<=10^{5}$ ) — the number of columns in the table.
Next three lines contain $n$ integers each — the description of the table. The $j$ -th number in the $i$ -th line corresponds to the cell $a_{ij}$ ( $-10^{9}<=a_{ij}<=10^{9}$ ) of the table.
Next three lines contain $n$ integers each — the description of the table. The $j$ -th number in the $i$ -th line corresponds to the cell $a_{ij}$ ( $-10^{9}<=a_{ij}<=10^{9}$ ) of the table.
输出格式
Output the maximum sum of numbers on a path from the upper left cell to the bottom right cell of the table, that doesn't visit any of the cells twice.
输入输出样例
输入 #1
3 1 1 1 1 -1 1 1 1 1
输出 #1
7
输入 #2
5 10 10 10 -1 -1 -1 10 10 10 10 -1 10 10 10 10
输出 #2
110
The path for the first example:
The path for the second example:

The path for the second example:

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