codeforce 855B
2 seconds
256 megabytes
standard input
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.
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 a single integer the maximum value of p·ai + q·aj + r·ak that can be obtained provided 1 ≤ i ≤ j ≤ k ≤ n.
5 1 2 3
1 2 3 4 5
30
5 1 2 -3
-1 -2 -3 -4 -5
12
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 }
最新文章
- 【腾讯GAD暑期训练营游戏程序班】游戏中的特效系统作业说明文档
- [转] 理解 Thread.Sleep 函数
- 配置ActiveX控件在网页中下载安装
- CSS-3 Animation 的使用
- 【Oracle 数据迁移】环境oracle 11gR2,exp无法导出空表的表结构【转载】
- spring2.5
- Android:apk文件结构
- 观锁与悲观锁(Hibernate)
- 基于visual Studio2013解决面试题之0609寻找链表公共节点
- ubuntu14操作系统chrome标签和书签乱码解决
- 13、Cocos2dx 3.0游戏开发找小三之3.0中的Director :郝萌主,一统江湖
- PL SQL Developer报错框乱码
- selenium-确定找到的element唯一(三)
- SQL HAVING 子句使用
- Elasticsearch数据迁移工具elasticdump工具
- C++中的局部变量、全局变量、局部静态变量、全局静态变量的区别
- uva-310-L--system-暴力枚举
- 如何在CentOS 7.2上创建NFS的Share,然后让Client可以访问
- Longest Palindromic Substring leetcode java
- python接口自动化发送get请求 详解(一)
热门文章
- VGA调试心得
- 说说C# 8.0 新增功能Index和Range的^0是什么?
- Django Full Coverage
- Python虚拟环境配置应用
- java-数据类型复习
- The OAuth 2.0 Authorization Framework OAuth2.0的核心角色code 扫码登录
- IntelliJ Idea 解决 Could not autowire. No beans of &#39;xxxx&#39; type found 的错误提示
- 《进击吧!Blazor!》第一章 3.页面制作
- 我的刷题单(8/37)(dalao珂来享受切题的快感
- 【笔记】学习markdown