【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 ...
随机推荐
- Codeforces-348E Pilgrims
#4342. CF348 Pilgrims 此题同UOJ#11 ydc的大树 Online Judge:Bzoj-4342,Codeforces-348E,Luogu-CF348E,Uoj-#11 L ...
- Windows API 第14篇 DeleteAndRenameFile
函数定义:BOOL DeleteAndRenameFile( LPCWSTR lpszDestFile, ...
- 转:Linux fork与vfork的深入分析
源地址:http://linux.chinaitlab.com/c/831529.html 一)fork的概述 .操作系统对进程的管理,是通过进程表完成的.进程表中的每一个表项,记录的是当前操作系统中 ...
- add-apt-repository ppa:<ppa_name>
add-apt-repository: add-apt-repository 是由 python-software-properties 这个工具包提供的 所以要先安装python-software- ...
- leetcode 321 Create Max Number
leetcode 321 Create Max Number greedy的方法,由于有两个数组,我们很自然的想到从数组1中选i个数,数组2中选k-i个数,这样我们只需要遍历max(0, k-数组2长 ...
- H5C3--媒体查询(向上兼容,向下覆盖),link中引入的ont and only
一.使用 实例: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- jmeter的组件介绍--框架
测试计划(test plan):用于存放测试脚本的容器. 线程(threads):通过java多线程来实现模拟多用户操作,只有在线程组下才能添加sample(各种协议的请求),因此线程是必须的. 取样 ...
- poj 2115 扩展欧几里德
#include<stdio.h> #include<string.h> #define max 32 typedef long long LL; LL pow2[max+]; ...
- JavaScript如何实现字符串拼接操作
实际应用中,目标字符串的生成可能需要多个数据的拼接. 由于应用频繁,几乎是所有编程语言都必须掌握的操作,当然每种语言具有各自特点. 本文将通过代码实例详细介绍一下JavaScript如何实现字符串拼接 ...
- jnhs-springmvc 请求组合不正确,比如请求路径出现两次
初学springmvc 向后台传参数,结果发现,一直404 404后没有路径,说明 没有进入controller 仔细一看,请求路径不对,重复出现 页面是这样写的 页面是这样写的 原因是,请求链接和当 ...