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

  2. Bootstrap--导航元素

    1.标签形导航 2.胶囊型导航: 3.垂直堆叠形导航: 4.导航加下拉菜单: 5.导航列表: 6.可切换的标签导航:

  3. UNIX时间与本地时间的转换

    所谓UNIX时间,维基百科的解释:UNIX时间,或称POSIX时间是UNIX或类UNIX系统使用的时间表示方式:从协调世界时1970年1月1日0时0分0秒起至现在的总秒数,不包括闰秒 知道了是什么,就 ...

  4. asp.net 分页类

    PaginatedList.cs using System;using System.Collections.Generic;using System.Linq;using System.Web; n ...

  5. js解析json,js转换json成map,获取map的key,value

    json串格式 { "10.10.11.1": { "target_1": "34.2", "target_3": &q ...

  6. iOS、mac开源项目及库(感谢原作者的分享)

    目录 模糊效果 富文本 表相关 HUD与Toast 其他UI 其他动画 网络测试 网络聊天 Model 数据库 PDF 摄像照相视频音频处理 消息相关 消息推送服务器端 版本新API的Demo 测试及 ...

  7. C#winform检测电脑安装的.netframework版本和是否安装了某软件

    代码如下: //C#获取已安装 .NET Framework 版本 private static string[] GetDotNetVersions() { DirectoryInfo[] dire ...

  8. SUN-LDAP6.3_RHEL 5.0-卸载LDAP

    卸载LDAP 1.注销服务器 到目录/ldap/ldapinstance/dscc6/bin下 # ./dsccreg remove-server -h 主机名 /ldap/ldapinstance/ ...

  9. 在Ubuntu下的Apache上建立新的website,以及enable mono

    1. 在Apache下建立新的web site a. $>cd /etc/apache2/ b. $>vi ports.conf 填加Listen 8090(注意不要打开8080,因为To ...

  10. JavaScript对象属性 constructor

     对象属性 constructor 属性返回对创建此对象的数组函数的引用; constructor(构造函数) 在对象创建或实例化时候被调用的方法.通常使用该方法来初始化数据成员和所需资源.构造函数不 ...