【Educational Codeforces Round 48 (Rated for Div. 2) C】 Vasya And The Mushrooms
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
显然在没有一直往右走然后走到头再往上走一格再往左走到头之前。
肯定是一直在蛇形走位。。
这个蛇形走位的答案贡献可以预处理出来。很容易。
然后蛇形走位之后走到最右再掉头的这个过程也能倒推出来。
考虑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的更多相关文章
- 【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix
[链接] 我是链接,点我呀:) [题意] 告诉你每一行.每一列的异或和. 让你求出一个符合要求的原矩阵. [题解] 显然应该有 a1^a2^....^an = b1^b2^....^bn 也即两边同时 ...
- 【Educational Codeforces Round 53 (Rated for Div. 2) C】Vasya and Robot
[链接] 我是链接,点我呀:) [题意] [题解] 如果|x|+|y|>n 显然.从(0,0)根本就没法到(x,y) 但|x|+|y|<=n还不一定就能到达(x,y) 注意到,你每走一步路 ...
- 【 Educational Codeforces Round 51 (Rated for Div. 2) F】The Shortest Statement
[链接] 我是链接,点我呀:) [题意] [题解] 先处理出来任意一棵树. 然后把不是树上的边处理出来 对于每一条非树边的点(最多21*2个点) 在原图上,做dijkstra 这样就能处理出来这些非树 ...
- 【Educational Codeforces Round 41 (Rated for Div. 2) D】Pair Of Lines
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 如果点的个数<=3 那么直接输出有解. 否则. 假设1,2最后会在一条直线上,则把这条直线上的点都删掉. 看看剩余的点是否在同 ...
- 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 ...
- Educational Codeforces Round 48 (Rated for Div. 2) CD题解
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ...
- Educational Codeforces Round 48 (Rated for Div. 2)
http://codeforces.com/contest/1016 A. 没想到这个也会TLE,太粗心了 B. 暴力就好了,多情况讨论又出错... 思路跟我一样的解法 为什么我做了那么多讨论,原 ...
- 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 ...
- 【Educational Codeforces Round 38 (Rated for Div. 2)】 Problem A-D 题解
[比赛链接] 点击打开链接 [题解] Problem A Word Correction[字符串] 不用多说了吧,字符串的基本操作 Problem B Run for your prize[贪心] ...
随机推荐
- 百度2016研发project师笔试题(四)
百度2016研发project师笔试题(四) 2015/12/8 10:42(网上收集整理的,參考答案在后面.若有错误请大神指出) 1. 关于MapReduce的描写叙述错误的是() A. 一个Tas ...
- HDU 1788 Chinese remainder theorem again 中国剩余定理
题意: 给定n,AA 以下n个数m1,m2···mn 则有n条方程 res % m1 = m1-AA res % m2 = m2-AA 问res的最小值 直接上剩余定理,嘿嘿 #include< ...
- 【cl】oracle之Sequence
sequence:序列 首先要有create sequence或者create any sequence权限: 1.语法如下: create sequence cltest---序列名 increm ...
- graphviz.js的图形及属性简单用法
digraph A { graph[bgcolor="cadetblue" label="图的标题" fontsize=48 fontcolor="g ...
- Swift_ios_二进制,十进制,十六进制之间的转换
这里所说的转换,并不是Swift中字面量之间的转换.如果是字面量之间的转换,ios系统中已经自动帮我们转换了. 例如let number1:Int = 8let number2:Int = 0b100 ...
- Dragon Ball--hdoj
Dragon Ball Problem Description Five hundred years later, the number of dragon balls will increase u ...
- [ASP.Net] MVC2,3,4,5的不同
现在MVC的技术日趋成熟,面对着不同版本的MVC大家不免有所迷惑 -- 它们之间有什么不同呢?下面我把我搜集的信息汇总一下,以便大家能更好的认识不同版本MVC的功能,也便于自己查阅. View Eng ...
- 深入理解 python 元类
一.什么的元类 # 思考: # Python 中对象是由实例化类得来的,那么类又是怎么得到的呢? # 疑问: # python 中一切皆对象,那么类是否也是对象?如果是,那么它又是那个类实例化而来的呢 ...
- BZOJ 1443 二分图博弈 网络流
思路: 二分图博弈嘛 找到最大匹配的必须点 跑个网络流 前后DFS一遍 //By SiriusRen #include <queue> #include <cstdio> #i ...
- HBase编程 API入门系列之delete(管理端而言)(9)
大家,若是看过我前期的这篇博客的话,则 HBase编程 API入门之delete(客户端而言) 就知道,在这篇博文里,我是在客户端里删除HBase表的. 这里,我带领大家,学习更高级的,因为,在开发中 ...