HDU5461 Largest Point(暴力)
这题第一眼就想到暴力。。
枚举每一个ti,就能确定tj,tj一定是剩下数最大或最小的。为了求tj就要求出数列最大最小次大次小。时间复杂度O(n)。
感觉暴力挺有趣的。
#include<cstdio>
#include<algorithm>
using namespace std;
__int64 arr[];
int main(){
int t;
scanf("%d",&t);
for(int cse=; cse<=t; ++cse){
__int64 n,a,b;
scanf("%I64d%I64d%I64d",&n,&a,&b);
for(int i=; i<=n; ++i){
scanf("%I64d",arr+i);
} __int64 max1=-,max2=-,min1=,min2=;
int maxi,mini;
for(int i=; i<=n; ++i){
if(max1<arr[i]) max1=arr[i], maxi=i;
if(min1>arr[i]) min1=arr[i], mini=i;
}
for(int i=; i<=n; ++i){
if(i!=maxi && max2<arr[i]) max2=arr[i];
if(i!=mini && min2>arr[i]) min2=arr[i];
} __int64 res=a*arr[]*arr[]+b*arr[];
for(int i=; i<=n; ++i){
__int64 tmp=arr[i]*arr[i]*a; if(max1==arr[i]) res=max(res,tmp+max2*b);
else res=max(res,tmp+max1*b); if(min1==arr[i]) res=max(res,tmp+min2*b);
else res=max(res,tmp+min1*b);
}
printf("Case #%d: %I64d\n",cse,res);
}
return ;
}
HDU5461 Largest Point(暴力)的更多相关文章
- hdu 5461 Largest Point 暴力
Largest Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...
- hdu5461 Largest Point(沈阳网赛)
Largest Point Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total ...
- HDU5461 Largest Point 思维 2015沈阳icpc
Largest Point Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tot ...
- hdu 5461(2015沈阳网赛 简单暴力) Largest Point
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5461 题意就是在数组中找出a*t[i]*t[i]+b*t[j]的最大值,特别注意的是这里i和i不能相等,想 ...
- [LeetCode] Largest Rectangle in Histogram 直方图中最大的矩形
Given n non-negative integers representing the histogram's bar height where the width of each bar is ...
- Split Array Largest Sum
Given an array which consists of non-negative integers and an integer m, you can split the array int ...
- [LeetCode] Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is ...
- Fishnet(暴力POJ 1408)
Fishnet Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 1911 Accepted: 1227 Descripti ...
- UVALive 7070 The E-pang Palace 暴力
The E-pang Palace Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/problem ...
随机推荐
- ios手势
iOS 手势操作:拖动.捏合.旋转.点按.长按.轻扫.自定义 大 中 小 1.UIGestureRecognizer 介绍 手势识别在 iOS 中非常重要,他极大地提高了移动设备的使用便捷性. i ...
- web前端开发学习:jQuery的原型中的init
web前端开发学习:jQuery的原型中的init 有大量web前端开发工具及学习资料,可以搜群[ web前端学习部落22群 ]进行下载,遇到学习问题也可以问群内专家以及课程老师哟 jQuery.fn ...
- ASCII 非打印字符
项目出了问题,因为AscII非打印字符的原因,后来找了一下啊ASCII的非打印字符,总共有31个,然后我们直接全部替换成问号了. 解决方式为先找到非打印字符,这是我从网上找的非打印字符表: 进制 十六 ...
- Hive学习路线图(转)
Hadoophivehqlroadmap学习路线图 1 Comment Hive学习路线图 Hadoop家族系列文章,主要介绍Hadoop家族产品,常用的项目包括Hadoop, Hive, Pig ...
- grep -i 不区分大小写
# rpm -qa|grep -i "mysql" MySQL-server--.rhel5.x86_64 MySQL-test--.rhel5.x86_64 MySQL-embe ...
- Linux常用命令学习1---(安装、文件系统、目录操作命令cd ls mv cp rm mkdir、链接命令ln……)
1.理解Linux的文件系统:分区和挂载点 挂载点和路径名无关 /根目录下的/boot完全可以时独立于 /的独立的挂载点,只要你设置就可以 linux安装时候,必须要有这两个分区 / 和 ...
- Win7系统怎么开启远程桌面?Win7远程桌面怎么用(转)
远程桌面服务开启之后,可以方便的远程管理服务器或计算机.为生活和工作带来不少便利呢,很多小伙伴还不知道怎么开启win7远程桌面吧(下面咗嚛以内网远程桌面为例) 工具/原料 Win7 Win7远程桌 ...
- FAST特征点检测
Features From Accelerated Segment Test 1. FAST算法原理 博客中已经介绍了很多图像特征检测算子,我们可以用LoG或者DoG检测图像中的Blobs(斑点检测) ...
- HDU 5869 Different GCD Subarray Query 离线+树状数组
Different GCD Subarray Query Problem Description This is a simple problem. The teacher gives Bob a ...
- Codeforces Beta Round #95 (Div. 2) D.Subway
题目链接:http://codeforces.com/problemset/problem/131/D 思路: 题目的意思是说给定一个无向图,求图中的顶点到环上顶点的最短距离(有且仅有一个环,并且环上 ...