【CF Manthan, Codefest 17 B】Marvolo Gaunt's Ring
【链接】h在这里写链接
【题意】
【题解】
有一个要求i<=j<=k;
也就是说系数之间的下标是有关系的。
枚举第一个位置的下标i;
则第二个人j
i<=j<n
枚举中间那个人的位置在哪。
求出前i个位置,第一个人能获得的最大值是多少
求出后n-i个位置,第三个人能获得的最大值是多少
*/
【错的次数】
【反思】
【代码】
#include <bits/stdc++.h>
#define LL long long
using namespace std; const int N = 1e5; int n;
LL pre[N+10],after[N+10];//前缀最大,后缀最大
LL a[N+10],p,q,r; int main()
{
//freopen("F:\\rush.txt", "r", stdin);
scanf("%d%lld%lld%lld", &n, &p, &q, &r);
for (int i = 1;i <= n;i++)
scanf("%lld",&a[i]);
pre[1] = p*a[1];
for (int i = 2;i <= n;i++) pre[i] = max(pre[i-1],p*a[i]);
after[n] = r*a[n];
for (int i = n-1;i >= 1;i--) after[i] = max(after[i+1],r*a[i]);
LL ans = pre[1]+after[1]+q*a[1];
for (int i = 2;i <= n;i++)
ans = max(ans,pre[i]+after[i]+q*a[i]);
printf("%lld\n",ans);
return 0;
}
【CF Manthan, Codefest 17 B】Marvolo Gaunt's Ring的更多相关文章
- 【CF Manthan, Codefest 17 A】Tom Riddle's Diary
[链接]h在这里写链接 [题意] 在这里写题意 [题解] /* Be careful. 二重循环枚举 */ [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/st ...
- 【codeforces Manthan, Codefest 17 C】Helga Hufflepuff's Cup
[链接]h在这里写链接 [题意] k是最高级别的分数,最高界别的分数最多只能有x个. 1<=k<=m; 和k相邻的点的分数只能小于k; n个点的树,问你每个 ...
- 【ST】【CF855B】 Marvolo Gaunt's Ring
传送门 Description 给定三个数 \(p~,~q~,~r~\),以及一个数组 \(a\), 找出三个数 \(i~,~j~,~k\) ,其中 \(i~\leq~j~\leq~k\) 最大化 \ ...
- Manthan, Codefest 17
A. Tom Riddle's Diary time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces 855B:Marvolo Gaunt's Ring(枚举,前后缀)
B. Marvolo Gaunt's Ring Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaun ...
- Codeforces 855B - Marvolo Gaunt's Ring
855B - Marvolo Gaunt's Ring 思路:①枚举a[j],a[i]和a[k]分别用前缀最小值最大值和后缀最小值和后缀最大值确定. ②dp,dp[i][j]表示到第j为止,前i+1个 ...
- Marvolo Gaunt's Ring(巧妙利用前后缀进行模拟)
Description Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as h ...
- B. Marvolo Gaunt's Ring 前缀后缀
B. Marvolo Gaunt's Ring 这种一般只有三个的都可以处理前缀和后缀,再枚举中间这个值. 这个和之前写过的C. Four Segments 前缀后缀 处理方式很像. #include ...
- 【CF contest/792/problem/E】
E. Colored Balls time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
随机推荐
- 快速I/O 51node 1406
#include <bits/stdc++.h> using namespace std; #define LL long long typedef pair<int,int> ...
- Windows API 第14篇 DeleteAndRenameFile
函数定义:BOOL DeleteAndRenameFile( LPCWSTR lpszDestFile, ...
- webapp中<meta>与css代码部署
1.页面头部标签申明 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" id="te ...
- Mybatis框架+原理
https://www.cnblogs.com/luoxn28/p/6417892.html(转载,蛮详细的)
- bzoj4788: [CERC2016]Bipartite Blanket
2019.1.9交流题,现在看还是不会,,, 如果只有一边,那么Hall定理即可. 两边?分别满足Hall定理,就是合法的! 证明(构造方案): 左集合先任意形成一个合法匹配,单点增量加入右集合和与右 ...
- Spring注解驱动开发(一)-----组件注册
注册bean xml方式 1.beans.xml-----很简单,里面注册了一个person bean <?xml version="1.0" encoding=" ...
- [C#] double指定有效位数格式化
C#里面指定小数位数格式化大家都知道 ff.ToString("F3") 可以指定精确到三位小数. 但是如何指定有效位数呢?方法是 ff.ToString("G3&quo ...
- 【JSOI2018】绝地反击
题面 50pts 首先当然是二分答案\(mid\), 对于每一个点,以它为圆心的圆,交上攻击轨道: 那么这个点到攻击轨迹的可达范围就是一段圆弧. 怎么求这段圆弧呢? 我们知道圆弧可以用其两端点对于圆心 ...
- 【DM8168学习笔记6】学习思路整理
DavinciDM8168的开发是一套大的系统,包括ARM.DSP.以及他们的通信协作.对学习思路做简单总结: 一. 对于整体框架的把握 参考了一些文章.介绍davinci整体基础知 ...
- Python爬虫笔记【一】模拟用户访问之验证码清理(4)
清理图片,对图片进行二值化,去边框,去干扰线,去点 from PIL import Image from pytesseract import * from fnmatch import fnmatc ...