【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 ...
随机推荐
- 一些常见的synthesis attribute
Noprune A Verilog HDL synthesis attribute that prevents the Quartus II software from removing a regi ...
- centos 重新编译php
说明:系统原来通过源码安装了php7.1.0.网上找了很多彻底删除原来php的办法,执行命令php -v PHP版本信息始终都在,说明方法都无用.自己大胆做了如下尝试,成功重新编译php 查找php ...
- 矩阵快速幂2 3*n铺方格
#include <iostream> #include <cstdlib> #include <cstring> #include <queue> # ...
- Location protocol 属性
Location protocol 属性 定义和用法 protocol 属性是一个可读可写的字符串,可设置或返回当前 URL 的协议. 语法 location.protocol <!DOCTYP ...
- Hibernate继承注解
hibernate应用中,继承的用途或目的主要有两点: 组件化:故明思义,把重复性的代码抽取成组件,以便重用和维护.hibernate应用中,一些重复的字段,重复的映射配置,就需要抽取成组件. 多态性 ...
- python实例5-表格打印
编写一个名为printTable()的函数,它接受字符串的列表的列表,将它显示在组织良好的表格中,每列右对齐.假定所有内层列表都包含同样数目的字符串.例如,该值可能看起来像这样: table_data ...
- Pandas怎样按条件删除行?
来自: https://stackoverflow.com/questions/13851535/delete-rows-from-a-pandas-dataframe-based-on-a-cond ...
- istio1.1(openshift) 流量路由
1.准备测试应用 准备两个nginx Pod和一个proxy 创建应用 apiVersion: apps.openshift.io/v1 kind: DeploymentConfig metadata ...
- loj2324 「清华集训 2017」小 Y 和二叉树
https://loj.ac/problem/2324 太智障,一开始以为中序遍历的第一个点一定是一个叶子,想了个贪心.然而,手算了一下,第一个点都过不了啊. input 5 2 3 4 1 3 3 ...
- CSP-S模拟 - 20190916
这是一套题=.= ABC D1DEF D2 过程-Process Before T1 像DP 迷茫…… T2 像二/三分 T3 不知道惹 可以DP($30\%$) During T1 先打个暴力$N^ ...