CF1016C.Vasya And The Mushrooms
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
瓦西娅的家位于一片森林中,附近有一片蘑菇草地。这片草地由两行组成,每行可划分为 n 个连续的格子。对于每个格子,瓦西娅都知道其中蘑菇的生长速度(更准确地说,是该格子每分钟长出多少克蘑菇)。瓦西娅恰好花费一分钟移动到某个相邻格子。瓦西娅不能离开草地。若两个格子具有公共边,则称它们相邻。当瓦西娅进入某个格子时,他会立即采集该格子中当前所有已生长的蘑菇。
瓦西娅从左上角的格子出发。每一分钟,瓦西娅必须移动到某个相邻格子,他不能停留等待蘑菇生长。他希望恰好访问每个格子一次,并使所采集蘑菇的总重量最大化。初始时刻,所有蘑菇的重量均为 0。注意:瓦西娅无需返回起始格子。
请帮助瓦西娅!计算他所能采集的蘑菇的最大总重量。
输入格式
The first line contains the number n (1 ≤ n ≤ 3·105) — the length of the glade.
The second line contains n numbers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 106) — 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 ≤ 106) is the growth rate of mushrooms in the second row of the glade.
第一行包含一个整数 n(1≤n≤3⋅105)——林中空地的长度。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤106)——空地第一行中蘑菇的生长速率。
第三行包含 n 个整数 b1,b2,…,bn(1≤bi≤106)——空地第二行中蘑菇的生长速率。
输出格式
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.
输出一个数字——Vasya 通过选择最优路径所能采集到的蘑菇的最大总重量。注意:Vasya 必须恰好访问林中空地的每个格子一次。
输入输出样例
输入#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.
在第一个测试用例中,最优路径如下所示:

因此,采集到的蘑菇总重量为 0⋅1+1⋅2+2⋅3+3⋅4+4⋅5+5⋅6=70。
在第二个测试用例中,最优路径如下所示:

因此,采集到的蘑菇总重量为 0⋅1+1⋅10+2⋅100+3⋅1000+4⋅10000+5⋅100000=543210。
输入解题思路,AI测评打分。不知道怎么写?