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的更多相关文章

  1. CF 1073C Vasya and Robot(二分答案)

    C. Vasya and Robot time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  2. 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 ...

  3. Codeforces 1073C:Vasya and Robot(二分)

    C. Vasya and Robot time limit per test: 1 secondmemory limit per test: 256 megabytesinput: standard ...

  4. C. Vasya and Robot二分

    1.题目描述 Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell ...

  5. CF 24 D. Broken robot

    D. Broken robot 链接. 题意: 一个方格,从(x,y)出发,等价的概率向下,向左,向右,不动.如果在左右边缘上,那么等价的概率不动,向右/左,向下.走到最后一行即结束.求期望结束的步数 ...

  6. CF1073C Vasya and Robot

    CF题目难度普遍偏高啊-- 一个乱搞的做法.因为代价为最大下标减去最小的下标,那么可以看做一个区间的修改.我们枚举选取的区间的右端点,不难发现满足条件的左端点必然是不降的.那么用一个指针移一下就好了 ...

  7. [CF355C]Vasya and Robot(思维,贪心)

    题目链接:http://codeforces.com/contest/355/problem/C 题意:1~n n个物品各重wi,现在有一个人可以从左边拿和从右边拿, 左边拿一个物品的花费是l*wi, ...

  8. CF 577C Vasya and Petya's Game

    题意:一个游戏,A童鞋在1~n的范围里猜一个数,B童鞋询问一个集合,A童鞋要对集合里每个数做出回答,他猜的数能否给整除,B要通过这些答案得到A猜的数,最少需要猜哪些数? 解法:一个数可以由若干个质数的 ...

  9. cf B. Vasya and Public Transport

    http://codeforces.com/contest/355/problem/B #include <cstdio> #include <cstring> #includ ...

随机推荐

  1. 【转】Beaglebone Black

    原文网址:http://bbs.eeworld.com.cn/thread-431409-1-1.html 开源硬件在国外火得一塌糊涂,国内却没有那么多人玩,直接导致中文论坛资料严重缺乏……但这也挡不 ...

  2. HDU_2021——最少RMB问题

    Problem Description 作为杭电的老师,最盼望的日子就是每月的8号了,因为这一天是发工资的日子,养家糊口就靠它了,呵呵但是对于学校财务处的工作人员来说,这一天则是很忙碌的一天,财务处的 ...

  3. CF- Day at the Beach

    C. Day at the Beach time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. bfs 记录和打印最短路径

    Poj3984 迷宫问题 #include <iostream> #include <algorithm> #include <cstdio> #include & ...

  5. AOJ 0118 深度优先搜索

    日文题... 题意:一个面积为H*W的果园,种了苹果,梨和蜜柑.相邻(上下左右)的果树属于同一个区域,问果园共有多少个区域. 分析:迷宫问题.对于每一个格子,可以用深度优先搜索把相同果树的格子遍历并标 ...

  6. 取得select框的text

    function selectInput(choose) {     alert(choose.options[choose.selectedIndex].text);  }

  7. # linux下安装Nodejs环境

    1.下载二进制文件到本地 root@ubuntu:/home/zhu/Downloads# node-v6.3.1-linux-x64.tar.xz 2.解压文件到当前文件夹 root@ubuntu: ...

  8. 浙江大学PAT上机题解析之5-05. QQ帐户的申请与登陆

    实现QQ新帐户申请和老帐户登陆的简化版功能.最大挑战是:据说现在的QQ号码已经有10位数了. 输入格式说明: 输入首先给出一个正整数N(<=105),随后给出N行指令.每行指令的格式为:“命令符 ...

  9. Android:Service的非绑定式的创建和生命周期

    Android的Service若使用非绑定式的创建,则创建后将无法再与它取得联系.即无法传递消息參数等: 所以假设希望创建后仍然与其存在联系,那么能够參考我的前几篇博客<Android:Serv ...

  10. c#中的面向对象基础知识总结

    面向对象 1.面向过程----->面向对象 1.  面向过程:面向的是完成这件事儿的过程,强调的是完成这件事儿的动作. 面向对象:意在写出一个通用的代码,屏蔽差异. 我们在代码中描述一个对象,通 ...