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 ...
随机推荐
- 【细说Java】揭开Java的main方法神秘的面纱
大家都知道,main方法是Java应用程序的入口,其定义格式为: public static void main(String[] args) 可是为什么要这么定义呢?不这样定义可以么?main方法可 ...
- Android中使用shape制作一个旋转的progressbar
public class ZNtestResActivity extends Activity { @Override public void onCreate(Bundle savedInstanc ...
- HDU_2040——判断亲和数
Problem Description 古希腊数学家毕达哥拉斯在自然数研究中发现,220的所有真约数(即不是自身的约数)之和为: 1+2+4+5+10+11+20+22+44+55+110=284. ...
- FZU2179/Codeforces 55D beautiful number 数位DP
题目大意: 求 1(m)到n直接有多少个数字x满足 x可以整出这个数字的每一位上的数字 思路: 整除每一位.只需要整除每一位的lcm即可 但是数字太大,dp状态怎么表示呢 发现 1~9的LCM 是2 ...
- [LeetCode] Course Schedule I (207) & II (210) 解题思路
207. Course Schedule There are a total of n courses you have to take, labeled from 0 to n - 1. Some ...
- html基础知识总结2
下拉列表,文本域,复选框 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> ...
- E - Redundant Paths - poj 3177(缩点求叶子节点)
题意:给一个图,想让每两个点之间都有两条路相连,不过特殊的是相同的两点之间多次相连被认为是一条边,现在求最少还需要添加几条边才能做到 分析:手欠没看清楚是相同的边只能相连一次,需要去重边,缩点后求出来 ...
- storm高级原语-Transactional topology
参考: http://xumingming.sinaapp.com/736/twitter-storm-transactional-topolgoy/ http://xumingming.sinaap ...
- struts2.1.3之后使用自定义Filter
struts2中 ActionContextCleanUp, StrutsPrepareAndExecuteFilter, StrutsPrepareFilter,StrutsExecuteFilte ...
- [Javascript] Intro to Recursion - Detecting an Infinite Loop
When using recursion, you must be mindful of the dreaded infinite loop. Using the recursive function ...