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

【题意】

在这里输入题意

【题解】

显然在没有一直往右走然后走到头再往上走一格再往左走到头之前。
肯定是一直在蛇形走位。。
这个蛇形走位的答案贡献可以预处理出来。很容易。
然后蛇形走位之后走到最右再掉头的这个过程也能倒推出来。
考虑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. 【cl】cmd相关命令

    cd  进入目录 dir  列出当前目录下的文件[在linux上是ls] e:  进入E盘 tab键可以快速进入目录

  2. JPA相关注解

    JPA注解 一.基本注解 1.表相关   @Entity   仅仅要加了这个注解就具备了表和实体的映射关系,表名就是实体名   @Table(name="表名")    一般和实体 ...

  3. luogu1072 Hankson的趣味题

    题目大意 给出数a0, a1, b0, b1,求满足gcd(a0, x)=a1, lcm(b0, x)=b1的x的个数 解法一 枚举b1的因数,看看是否满足上述条件. 怎样枚举因数 试除法.对于1~s ...

  4. yolo源码解析(3):视频检测流程

    代码在自己电脑中!!!!不在服务器 根据前文所说yolo代码逻辑: ├── examples │ ├── darknet.c(主程序) │ │── xxx1.c │ └── xxx2.c │ ├── ...

  5. vim下很好的右键复制方法

    1)先按shift ,然后鼠标选中即可复制:(shift按下时为非vim环境) 2)好方法: "Enable and disable mouse use noremap <f1> ...

  6. 为了世界的和平~一起上caioj~~~!

    打Call~打Call~打Call~~~!!! 世界毁灭了你在哪???不要犹豫,快去caioj!!! 无比优质的oj,未来大牛的明智之选----就是caioj~~~

  7. hdoj-1827-Summer Holiday(scc+缩点)

    Summer Holiday Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  8. 【IOI 1994】 The Buses

    [题目链接] http://poj.org/problem?id=1167 [算法] 深度优先搜索 + 迭代加深 [代码] #include <algorithm> #include &l ...

  9. JPA设置表名和实体名,表字段与实体字段的对应

    转自:https://blog.csdn.net/LQW_java_home/article/details/53079363 首先 你的jpaProperties配置项中要有 <prop ke ...

  10. POJ 1416 DFS

    题目翻译: 公司现在要发明一种新的碎纸机,要求新的碎纸机能够把纸条上的数字切成最接近而不超过target值.比如,target的值是50,而纸条上的数字是12346,应该把数字切成四部分,分别是1.2 ...