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

枚举每一个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. arcgis

    投影的时候两个选择: projected:平面的,以米为单位 另一个:球迷的,以经纬度为单位

  2. ASP.NET SignalR 与 LayIM2.0 配合轻松实现Web聊天室(四) 之 用户搜索(Elasticsearch),加好友流程(1)。

    前面几篇基本已经实现了大部分即时通讯功能:聊天,群聊,发送文件,图片,消息.不过这些业务都是比较粗犷的.下面我们就把业务细化,之前用的是死数据,那我们就从加好友开始吧.加好友,首先你得知道你要加谁.L ...

  3. iOS 语录

    1. 输入法切换: cmd + space 2. xcode 退出全屏control + cmd + f 3. xcode 代码格式化插件Uncrustify,XAlign, CLangFormat ...

  4. js对象的创建与原型总结

    //1 新建对象 var box = new Object(); box.name = "lee"; box.age = 100; box.run = function(){ re ...

  5. IOS开发中有用的第三方库

    #Objective-C中最受瞩目库 [链接](https://github.com/languages​​/Objective-C/most_watched) * [three20](https:/ ...

  6. Android Programming: Pushing the Limits -- Chapter 4: Android User Experience and Interface Design

    User Stories Android UI Design 附加资源 User Stories: @.通过写故事来设计应用. @.每个故事只关注一件事. @.不同的故事可能使用相同的组件,因此尽早地 ...

  7. samba 报错

    [root@GitLab data_nfs]# smbclient //localhost/public WARNING: The security=share option is deprecate ...

  8. Linux SNMP oid

    http://www.debianadmin.com/linux-snmp-oids-for-cpumemory-and-disk-statistics.html

  9. HTML学习之Web存储(五)

    本地数据库功能大大增强了Web应用对于本地存储数据的方式和功能.Web时代真正进入了:“客户端为重,服务端为轻的时代”. <!DOCTYPE html> <html xmlns=&q ...

  10. Pyqt QSystemTrayIcon 实现托盘效果

    pyqt的托盘效果很好实现,在Pyqt的demo中有个例子 路径:PyQt4\examples\desktop\systray.py 今天我就仿这个Tray效果做效果 一. 创建UI trayicon ...