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

枚举每一个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. October 1st 2016 Week 40th Saturday

    Autumn, the year's last, loveliest smile. 秋,四季流转中的最后一抹,也是最美的那一抹微笑. I love autumn because it is the h ...

  2. vs2013中项目依赖项的作用

    依赖项就是设定项目所以来的项目,以决定具体生成解决方案时,项目编译的顺序(一般一个解决方案会有很多项目组成). 通常来说,依赖项取决于这个项目引用的组件和项目,系统可以自己决定. 作用就是让系统知道你 ...

  3. selenium--python如何定位一组元素并返回文本值

    from selenium import webdriverimport time a=[] #创建一个空列表用于存储查询到的元素组driver = webdriver.Firefox()driver ...

  4. Webstorm & PhpStorm的序列号和证书

    WebStorm注册码 User Name: EMBRACE License Key: ===== LICENSE BEGIN ===== 24718-12042010 00001h6wzKLpfo3 ...

  5. Python 调试 PDB

    出处:http://blog.163.com/gjx0619@126/blog/static/12740839320114995947700/ 完整 请参考:http://docs.python.or ...

  6. poj 2262【素数表的应用---判断素数】【哈希】

    Goldbach's Conjecture Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 35214   Accepted: ...

  7. 知乎大牛的关于JS解答

    很多疑惑一扫而空.... http://www.zhihu.com/question/35905242?sort=created JS的单线程,浏览器的多进程,与CPU,OS的对位. 互联网移动的起起 ...

  8. Windows+Git+TortoiseGit+COPSSH 安装图文教程

    转自:http://blog.csdn.net/aaron_luchen/article/details/10498181 准备工作: 1. Git-1.8.1.2-preview20130201.e ...

  9. 关于Application Insights遥测功能使用【遇到问题】

    简介:Application Insights是微软发布的一个在线服务,可以监测自己的网站应用,进行性能管理以及使用分析. Application Insights功能一开始是出现在Visualstu ...

  10. 汇编学习(一)——win7 64位调出debug

    一.安装方法: 1.下载一个dosbox和win7 32位debug.exe,安装dosbox,打开页面 2. 将debug.exe放入磁盘根目录,这里以D盘为例.在dosbox中输入mount c ...