A11891 | Vasya And The Mushrooms
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasya's house is situated in a forest, and there is a mushroom glade near it. The glade consists of two rows, each of which can be divided into $n$ consecutive cells. For each cell Vasya knows how fast the mushrooms grow in this cell (more formally, how many grams of mushrooms grow in this cell each minute). Vasya spends exactly one minute to move to some adjacent cell. Vasya cannot leave the glade. Two cells are considered adjacent if they share a common side. When Vasya enters some cell, he instantly collects all the mushrooms growing there.
Vasya begins his journey in the left upper cell. Every minute Vasya must move to some adjacent cell, he cannot wait for the mushrooms to grow. He wants to visit all the cells exactly once and maximize the total weight of the collected mushrooms. Initially, all mushrooms have a weight of $0$ . Note that Vasya doesn't need to return to the starting cell.
Help Vasya! Calculate the maximum total weight of mushrooms he can collect.
Vasya begins his journey in the left upper cell. Every minute Vasya must move to some adjacent cell, he cannot wait for the mushrooms to grow. He wants to visit all the cells exactly once and maximize the total weight of the collected mushrooms. Initially, all mushrooms have a weight of $0$ . Note that Vasya doesn't need to return to the starting cell.
Help Vasya! Calculate the maximum total weight of mushrooms he can collect.
输入格式
The first line contains the number $n (1<=n<=3·10^{5})$ — the length of the glade.
The second line contains $n$ numbers $a_{1},a_{2},...,a_{n} (1<=a_{i}<=10^{6})$ — the growth rate of mushrooms in the first row of the glade.
The third line contains $n$ numbers $b_{1},b_{2},...,b_{n} (1<=b_{i}<=10^{6})$ is the growth rate of mushrooms in the second row of the glade.
The second line contains $n$ numbers $a_{1},a_{2},...,a_{n} (1<=a_{i}<=10^{6})$ — the growth rate of mushrooms in the first row of the glade.
The third line contains $n$ numbers $b_{1},b_{2},...,b_{n} (1<=b_{i}<=10^{6})$ is the growth rate of mushrooms in the second row of the glade.
输出格式
Output one number — the maximum total weight of mushrooms that Vasya can collect by choosing the optimal route. Pay attention that Vasya must visit every cell of the glade exactly once.
输入输出样例
输入 #1
3 1 2 3 6 5 4
输出 #1
70
输入 #2
3 1 1000 10000 10 100 100000
输出 #2
543210
In the first test case, the optimal route is as follows:
 Thus, the collected weight of mushrooms will be $0·1+1·2+2·3+3·4+4·5+5·6=70$ .In the second test case, the optimal route is as follows:
 Thus, the collected weight of mushrooms will be $0·1+1·10+2·100+3·1000+4·10000+5·100000=543210$ .
 Thus, the collected weight of mushrooms will be $0·1+1·2+2·3+3·4+4·5+5·6=70$ .In the second test case, the optimal route is as follows:
 Thus, the collected weight of mushrooms will be $0·1+1·10+2·100+3·1000+4·10000+5·100000=543210$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted