首页 技术 正文
技术 2022年11月22日
0 收藏 712 点赞 4,579 浏览 1602 个字

B. Marvolo Gaunt’s Ringtime limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt’s Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he wants to give Dumbledore exactly x drops of the potion he made.

Value of x is calculated as maximum of p·ai + q·aj + r·ak for given p, q, r and array a1, a2, … an such that 1 ≤ i ≤ j ≤ k ≤ n. Help Snape find the value of x. Do note that the value of x may be negative.

Input

First line of input contains 4 integers n, p, q, r ( - 109 ≤ p, q, r ≤ 109, 1 ≤ n ≤ 105).

Next line of input contains n space separated integers a1, a2, … an ( - 109 ≤ ai ≤ 109).

Output

Output a single integer the maximum value of p·ai + q·aj + r·ak that can be obtained provided 1 ≤ i ≤ j ≤ k ≤ n.

ExamplesInput

5 1 2 3
1 2 3 4 5

Output

30

Input

5 1 2 -3
-1 -2 -3 -4 -5

Output

12

Note

In the first sample case, we can take i = j = k = 5, thus making the answer as 1·5 + 2·5 + 3·5 = 30.

In second sample case, selecting i = j = 1 and k = 5 gives the answer 12.

这题题意是给定p,q,r,要求从数组中选择 i,j,k  (i<=j<=k)

使得 p*i + q*j + r*k 最大,就是道暴力模拟水题,我竟然没有想到T T,直接掉了80分。。。

哇,我真的是个智障。

附ac代码:

 1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <map>
7 #define ll long long
8 using namespace std;
9 const ll inf = -4*1e18-5;
10
11 int main() {
12 int n;
13 scanf("%d",&n);
14 ll p,q,r;
15 scanf("%lld%lld%lld",&p,&q,&r);
16 ll u,m1,m2,m3;
17 // printf("%lld ",inf);
18 m1 = m2 = m3 =inf;
19 while(n--) {
20 scanf("%lld",&u);
21 m1 = max(m1,u*p);
22 m2 = max(m2,u*q + m1);
23 m3 = max(m3,u*r + m2);
24 }
25 printf("%lld\n",m3);
26 return 0;
27 }
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,023
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,513
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,360
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,143
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,774
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,852