Codeforces Round #206 (Div. 2) C - Vasya and Robot
来源:互联网 发布:网络协议软件 编辑:程序博客网 时间:2024/04/29 05:47
由于后台初始数据的弱,没有经验这个还是很坑的。。。
1.特判1没考虑
2.漏掉了极端情况
3.没有处理前缀和TLE
4.起初考虑时方向偏了,不是dp
#include <iostream>#include <vector>#include <stack>#include <cstring>#include <cmath>#include <cstdlib>#include <map>#include <queue>#include <set>#include <cstdio>#include <algorithm>using namespace std;/* define */#define sf(a) scanf("%d",&a)#define sfs(a) scanf("%s",a)#define sfI(a) scanf("%I64d",&a)#define pf(a) printf("%d\n",a)#define pfI(a) printf("%I64d\n",a)#define rep(i,a,b) for(int i=(a);i<=(b);i++)#define clr(a) memset(a,0,sizeof(a))/* define */typedef long long ll;const int N = 150000;const ll inf = (ll)1<<50;int n,l,r,Ql,Qr;int w[N],sum[N];ll sol(int x){ ll ans=0; int _ll=x,rr=n-x; ans+=(ll)sum[_ll]*l; ans+=(ll)(sum[n]-sum[x])*r; if(rr>_ll) ans+=(ll)(rr-_ll-1)*Qr; else if(rr<_ll) ans+=(ll)(_ll-rr-1)*Ql; return ans;}int main(){ while(~scanf("%d%d%d%d%d",&n,&l,&r,&Ql,&Qr)){ rep(i,1,n) sf(w[i]); if(n==1){ printf("%I64d\n",min((ll)w[1]*r,(ll)w[1]*l)); continue; } clr(sum); rep(i,1,n) sum[i]=sum[i-1]+w[i]; ll ans=inf; rep(i,0,n){ ans=min(ans,sol(i)); } pfI(ans); }}
- Codeforces Round #206 (Div. 2) C - Vasya and Robot
- Codeforces Round #206 (Div. 2) C. Vasya and Robot
- Codeforces Round #206 (Div. 2) C-Vasya and Robot
- Codeforces Round #206 (Div. 1) A. Vasya and Robot
- Codeforces Round #324 (Div. 2)C. Marina and Vasya
- Codeforces Round #324 (Div. 2) 584C. Marina and Vasya
- Codeforces Round #324 (Div. 2) C. Marina and Vasya
- Codeforces Round #354 (Div. 2)676C. Vasya and String
- Codeforces Round #354 (Div. 2) C .Vasya and String
- Codeforces Round #354 (Div. 2)-C. Vasya and String
- Codeforces Round #354 (Div. 2) C Vasya and String
- Codeforces Round #324 (Div. 2)C. Marina and Vasya
- Codeforces Round #354 (Div. 2)C. Vasya and String
- Codeforces Round #281 (Div. 2) C. Vasya and Basketball&D. Vasya and Chess
- Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
- Codeforces Round #206 (Div. 2) B. Vasya and Public Transport
- Codeforces Round #206 (Div. 2) E. Vasya and Beautiful Arrays
- Codeforces Round #206 (Div. 2) E-Vasya and Beautiful Arrays
- 数据库设计中的三大范式概念
- Unity3D入门(三):创建对象
- cxgrid不可以修改用union all语句组合的表
- Java产生特定范围内的随机整数
- UVa 10507 - Waking up brain
- Codeforces Round #206 (Div. 2) C - Vasya and Robot
- oracle动态性能表
- oracle创建表空间
- oracle用户权限,系统权限
- Unity3D入门(四):摄像机控制
- shell script 脚本传递参数的方法
- UITableView执行顺序及Segue必须要实现的方法
- UVa 10075 - Airlines
- php判断网页是否gzip压缩