【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

显然在没有一直往右走然后走到头再往上走一格再往左走到头之前。
肯定是一直在蛇形走位。。
这个蛇形走位的答案贡献可以预处理出来。很容易。
然后蛇形走位之后走到最右再掉头的这个过程也能倒推出来。
考虑sum[i]和sum[i+1]的转移就好
显然sum[i]只是多了a[i]和b[i]两个格子。
考虑它们的贡献就好。
sum[i]表示从i开始一直走到右,然后再走到左的花费。(且i位置作为t=0
(之后只要把i后面的和乘上之前过的时间elapsed+sum[i],那么就变成t=elapsed开始的啦
但是往右走有两种可能。一种是从a[i]开始。另外一种是从b[i]开始。
所以sum得开成两维的。
枚举一下从哪里开始,之后一直往右走再一直往左走就可以了。
注意爆int的问题。

【代码】

#include <bits/stdc++.h>
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define lson l,mid,rt<<1
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define rson mid+1,r,rt<<1|1
using namespace std; const double pi = acos(-1);
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};
const int N = 3e5; int n;
int a[2][N+10];
LL right_to_left[2][N+10],sum2[N+10],cur,ans; int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ri(n);
rep1(i,0,1)
rep1(j,1,n)
ri(a[i][j]);
rep2(i,n,1){
sum2[i] = sum2[i+1]+a[0][i]+a[1][i];
}
rep2(i,n,1){
right_to_left[0][i] = right_to_left[0][i+1] + sum2[i+1] + 0*a[0][i] + 1LL*((n-i+1)*2-1)*a[1][i];
right_to_left[1][i] = right_to_left[1][i+1] + sum2[i+1] + 0*a[1][i] + 1LL*((n-i+1)*2-1)*a[0][i];
}
cur = 0;
ans = right_to_left[0][1];
rep1(i,1,n){
if (i&1){
LL time_elapsed = (i-1)*2;
cur+=time_elapsed*a[0][i];
time_elapsed++;
cur+=time_elapsed*a[1][i];
ans = max(ans,1LL*(cur+(time_elapsed+1)*sum2[i+1]+right_to_left[1][i+1]));
}else{
LL time_elapsed = (i-1)*2;
cur+=time_elapsed*a[1][i];
time_elapsed++;
cur+=time_elapsed*a[0][i];
ans = max(ans,1LL*(cur+(time_elapsed+1)*sum2[i+1]+right_to_left[0][i+1]));
}
}
cout<<ans<<endl;
return 0;
}

【Educational Codeforces Round 48 (Rated for Div. 2) C】 Vasya And The Mushrooms的更多相关文章

  1. 【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix

    [链接] 我是链接,点我呀:) [题意] 告诉你每一行.每一列的异或和. 让你求出一个符合要求的原矩阵. [题解] 显然应该有 a1^a2^....^an = b1^b2^....^bn 也即两边同时 ...

  2. 【Educational Codeforces Round 53 (Rated for Div. 2) C】Vasya and Robot

    [链接] 我是链接,点我呀:) [题意] [题解] 如果|x|+|y|>n 显然.从(0,0)根本就没法到(x,y) 但|x|+|y|<=n还不一定就能到达(x,y) 注意到,你每走一步路 ...

  3. 【 Educational Codeforces Round 51 (Rated for Div. 2) F】The Shortest Statement

    [链接] 我是链接,点我呀:) [题意] [题解] 先处理出来任意一棵树. 然后把不是树上的边处理出来 对于每一条非树边的点(最多21*2个点) 在原图上,做dijkstra 这样就能处理出来这些非树 ...

  4. 【Educational Codeforces Round 41 (Rated for Div. 2) D】Pair Of Lines

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 如果点的个数<=3 那么直接输出有解. 否则. 假设1,2最后会在一条直线上,则把这条直线上的点都删掉. 看看剩余的点是否在同 ...

  5. Educational Codeforces Round 48 (Rated for Div. 2) D 1016D Vasya And The Matrix (构造)

    D. Vasya And The Matrix time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  6. Educational Codeforces Round 48 (Rated for Div. 2) CD题解

    Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...

  7. Educational Codeforces Round 48 (Rated for Div. 2)

    http://codeforces.com/contest/1016 A. 没想到这个也会TLE,太粗心了 B. 暴力就好了,多情况讨论又出错... 思路跟我一样的解法   为什么我做了那么多讨论,原 ...

  8. Educational Codeforces Round 48 (Rated for Div. 2) B 1016B Segment Occurrences (前缀和)

    B. Segment Occurrences time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  9. 【Educational Codeforces Round 38 (Rated for Div. 2)】 Problem A-D 题解

    [比赛链接] 点击打开链接 [题解] Problem A Word Correction[字符串] 不用多说了吧,字符串的基本操作 Problem B  Run for your prize[贪心] ...

随机推荐

  1. 通过UrlRewriter配置MVC4伪静态

    有些项目须要设置静态.这样能够被站点收录了,提高站点的排名.内容. 假设地址后面有www.a.com/xx.html?id=1是不行,还是不能达到一些需求.怎么才干实现www.a.com/1/xx.h ...

  2. winform设置超时时间

    ); //设置超时时间 var completedTask = await Task.WhenAny(new Task(async () => { );//执行的方法示例这里用延迟代替 }), ...

  3. jquery 页眉单行信息滚动显示

    JSP: 下面是控制滚动的样式.将滚动的内容查询出来.放在一个div 或者别的容器里面,我这里使用的是<dt> <style> #newCglist{width:300px;h ...

  4. Value Stewardship Over Showmanship

     Value Stewardship Over Showmanship Barry Hawkins WHEn An ARCHiTECT EnTERS A pRojECT, there is an u ...

  5. 关于ShapeDrawable应用的一些介绍(下)

    我们今天接着来看一下Shape中的stroke属性,stroke其实就是边缘的意思,当我们在定义画笔的时候,有很多时候会用到 FILL 和 STROKE,前者能够画出一个实心的形状,而后者就画出一个空 ...

  6. 字符串函数---strcmp()与strncmp()详解及实现【转】

    本文转载自:http://blog.csdn.net/lanzhihui_10086/article/details/39829623 一.strcmp()与strncmp() strcmp():st ...

  7. C - Puzzles

    Problem description The end of the school year is near and Ms. Manana, the teacher, will soon have t ...

  8. 1) 十分钟学会android--建立第一个APP,创建android项目

    一个Android项目包含了所有构成Android应用的源代码文件. 本小节介绍如何使用Android Studio或者是SDK Tools中的命令行来创建一个新的项目. Note:在此之前,我们应该 ...

  9. Domain=NSOSStatusErrorDomain Code=1937337955 关于iOS录音AVAudioRecorder与音频播放AVAudioPlayer真机调试录音不能播放的问题

    error:Domain=NSOSStatusErrorDomain Code=1937337955 ,这个错误很常见, 原因是因为我们需要调用另外一个AVAudioPlayer 的初始化方法,来确定 ...

  10. class A<T> where T:new()相关知识点

    来源:http://www.cnblogs.com/FredWang/p/4284251.html class A<T> where T:new()  ===>>>   ...