cf C. Vasya and Robot
http://codeforces.com/contest/355/problem/C
枚举L和R相交的位置。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const __int64 inf=1e19; int n,l,r,ql,qr;
int w[];
int sum1[];
int sum2[];
__int64 min1(__int64 a,__int64 b)
{
if(a>b) return b;
else return a;
} int main()
{
while(scanf("%d%d%d%d%d",&n,&l,&r,&ql,&qr)!=EOF)
{
for(int i=; i<=n; i++)
{
scanf("%d",&w[i]);
sum1[i]=sum1[i-]+w[i];
}
for(int i=n; i>=; i--)
{
sum2[i]=sum2[i+]+w[i];
}
__int64 ans=inf;
for(int i=; i<=n; i++)
{
int sum=(sum1[i]*l+sum2[i+]*r);
if(i>n-i) sum+=(*i-n-)*ql;
else if(i<n-i) sum+=(n-*i-)*qr;
ans=min1(ans,(__int64)sum);
}
printf("%I64d\n",ans);
}
return ;
}
cf C. Vasya and Robot的更多相关文章
- CF 1073C Vasya and Robot(二分答案)
C. Vasya and Robot time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Educational Codeforces Round 53 (Rated for Div. 2) C. Vasya and Robot 【二分 + 尺取】
任意门:http://codeforces.com/contest/1073/problem/C C. Vasya and Robot time limit per test 1 second mem ...
- Codeforces 1073C:Vasya and Robot(二分)
C. Vasya and Robot time limit per test: 1 secondmemory limit per test: 256 megabytesinput: standard ...
- C. Vasya and Robot二分
1.题目描述 Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell ...
- CF 24 D. Broken robot
D. Broken robot 链接. 题意: 一个方格,从(x,y)出发,等价的概率向下,向左,向右,不动.如果在左右边缘上,那么等价的概率不动,向右/左,向下.走到最后一行即结束.求期望结束的步数 ...
- CF1073C Vasya and Robot
CF题目难度普遍偏高啊-- 一个乱搞的做法.因为代价为最大下标减去最小的下标,那么可以看做一个区间的修改.我们枚举选取的区间的右端点,不难发现满足条件的左端点必然是不降的.那么用一个指针移一下就好了 ...
- [CF355C]Vasya and Robot(思维,贪心)
题目链接:http://codeforces.com/contest/355/problem/C 题意:1~n n个物品各重wi,现在有一个人可以从左边拿和从右边拿, 左边拿一个物品的花费是l*wi, ...
- CF 577C Vasya and Petya's Game
题意:一个游戏,A童鞋在1~n的范围里猜一个数,B童鞋询问一个集合,A童鞋要对集合里每个数做出回答,他猜的数能否给整除,B要通过这些答案得到A猜的数,最少需要猜哪些数? 解法:一个数可以由若干个质数的 ...
- cf B. Vasya and Public Transport
http://codeforces.com/contest/355/problem/B #include <cstdio> #include <cstring> #includ ...
随机推荐
- 基本排序算法:Python实现
基本排序算法,包括冒泡排序,插入排序,选择排序,堆排序,快速排序等. [冒泡排序] 复杂度是n*n #coding:utf8 #author:HaxtraZ #description:冒泡排序 def ...
- java调优随记-堆和栈
基础知识: 关于堆和栈,堆和栈是程序运行的关键,关于堆和栈的定义和解释可自行搜索,我比较认可以程序运行过程中他们扮演的角色作为对比的点:堆是存储的单位,而栈是程序运行时的单位.栈解决的是程序的运行问题 ...
- AngularJs中文社区学习资料
AngularJs中文社区学习资料,供学习: http://angularjs.cn/tag/AngularJS
- AngularJS和ReactJS对比
Angular的特点: 优势: AngularJS是一套完整的框架,angular有自带的数据绑定.render渲染.angularUI库,过滤器,$filter,$directive(模板),$se ...
- Python进阶(面向对象编程基础)(四)
1.方法也是属性 我们在 class 中定义的实例方法其实也是属性,它实际上是一个函数对象: class Person(object): def __init__(self, name, score) ...
- IOS设计模式学习(18)模板方法
1 前言 模板方法模式是面向对象软件设计中一种非常简单的设计模式.其基本思想是在抽象类的一个方法定义“标准”算法.在这个方法中调用的基本操作由子类重载予以实现.这个方法成为“模板”.因为方法定义的算法 ...
- .net程序开发人员必看的变量的命名规则
(1)类名.属性名.方法名采用Pascal命名,如 class User { } interface IEditable { } bool ValidateInput() public int Age ...
- 关于Discuz!nt论坛编辑器图片上传bug,flash域的问题
正在整discuz!nt,现在没有什么人弄了把? 上个星期突然来了个bug,搞死我了,论坛图片不能上传,上传卡在100%没反应了,于是我发现ajax发送到AttachUpload.cs时queryst ...
- 【socket.io研究】2.小试牛刀
1.建立个项目,也就是文件夹,这里使用testsocket 2.创建文件package.json,用于描述项目: { "name":"testsocket", ...
- SQlserver表连接
连接是两元运算,可以对两个或多个表进行查询,结果通常是含有参加连接运算的两个表或多个表的指定列的表. 在T-SQL中,连接查询有两类: 第一类:符合SQL标准的连接谓词表示形式: 第二类:T-SQL扩 ...