这题第一眼就想到暴力。。

枚举每一个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(暴力)的更多相关文章

  1. hdu 5461 Largest Point 暴力

    Largest Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...

  2. hdu5461 Largest Point(沈阳网赛)

    Largest Point Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total ...

  3. HDU5461 Largest Point 思维 2015沈阳icpc

    Largest Point Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tot ...

  4. hdu 5461(2015沈阳网赛 简单暴力) Largest Point

    题目;http://acm.hdu.edu.cn/showproblem.php?pid=5461 题意就是在数组中找出a*t[i]*t[i]+b*t[j]的最大值,特别注意的是这里i和i不能相等,想 ...

  5. [LeetCode] Largest Rectangle in Histogram 直方图中最大的矩形

    Given n non-negative integers representing the histogram's bar height where the width of each bar is ...

  6. Split Array Largest Sum

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

  7. [LeetCode] Largest Rectangle in Histogram

    Given n non-negative integers representing the histogram's bar height where the width of each bar is ...

  8. Fishnet(暴力POJ 1408)

    Fishnet Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1911   Accepted: 1227 Descripti ...

  9. 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 ...

随机推荐

  1. 绿色通道(codevs 3342)

    题目描述 Description <思远高考绿色通道>(Green Passage, GP)是唐山一中常用的练习册之一,其题量之大深受lsz等许多oiers的痛恨,其中又以数学绿色通道为最 ...

  2. Innodb之表空间转移

    我们可以将数据表转移到其他磁盘,以减弱单个磁盘的IO. 如 1创建一个表空间: 2修改表以使用新的表空间,如果表有大量数据,则会需要一些时间重建:所以会锁表一段时间: Note:会将原有的表空间删除, ...

  3. c++ 头文件包含问题-include&class

    http://blog.csdn.net/jiajia4336/article/details/8996254 前向声明概念(forward declaration) 在程序中引入了类类型的B.在声明 ...

  4. 求sqrt()底层效率问题(二分/牛顿迭代)

    偶然看见一段求根的神代码,于是就有了这篇博客: 对于求根问题,通常我们可以调用sqrt库函数,不过知其然需知其所以然,我们看一下求根的方法: 比较简单方法就是二分咯: 代码: #include< ...

  5. NYOJ题目822画图

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAtUAAAHzCAIAAABgzHaKAAAgAElEQVR4nO3dPVLjzBoG0LsJ514IsR

  6. MVC - 19.Log4net

    下载地址:http://pan.baidu.com/s/1gdxQegN   对于网站来讲,我们不能将异常信息显示给用户, Log4Net用来记录日志,可以将程序运行过程中的信息输出到文件,数据库中等 ...

  7. Linux性能分析工具的安装和使用

    转自:http://blog.chinaunix.net/uid-26488891-id-3118279.html Normal 0 7.8 磅 0 2 false false false EN-US ...

  8. Pyqt 窗体间传值

    窗体间传值网上有好多方法,比如新建文件,先将子类窗体的数据传到文件中,父窗体读取文件.  Signal&Slot机制进行传值 等等 在这里,我们就举个采用apply方法:Signal& ...

  9. [LeetCode] Longest Consecutive Sequence

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. F ...

  10. POJ3691 DNA repair(AC自动机 DP)

    给定N个长度不超过20的模式串,再给定一个长度为M的目标串S,求在目标串S上最少改变多少字符,可以使得它不包含任何的模式串 建立Trie图,求得每个节点是否是不可被包含的串,然后进行DP dp[i][ ...