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

枚举每一个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. ubuntu 添加环境变量

    转自:http://hi.baidu.com/mario05/item/02b6d60ff7371136a2332a48 Ubuntu Linux系统环境变量配置文件:/etc/profile : 在 ...

  2. 根据复选框checkbox的选中状态来打开或关闭隐藏层

    HTML:  <input type="checkbox" id="check-expert"> <div id="expert&q ...

  3. Swift - 文本输入框(UITextField)

    1,文本框的创建,有如下几个样式: UITextBorderStyle.none:无边框 UITextBorderStyle.line:直线边框 UITextBorderStyle.roundedRe ...

  4. find 查找文件 -exec 然后压缩 查看tar包的内容

    [root@cs Downloads]# find ./ -name "banner*" -exec tar -cvf k.tar "{}" \; ./bann ...

  5. CLR via C#(02)-基元类型、引用类型、值类型

    http://www.cnblogs.com/qq0827/p/3281150.html 一. 基元类型 编译器能够直接支持的数据类型叫做基元类型.例如int, string等.基元类型和.NET框架 ...

  6. CLR via C#(01)-.NET平台下代码是怎么跑起来的

    1. 源代码编译为托管模块 程序在.NET框架下运行,首先要将源代码编译为托管模块.CLR是一个可以被多种语言所使用的运行时,它的很多特性可以用于所有面向它的开发语言.微软开发了多种语言的编译器,编译 ...

  7. jquery学习笔记----jquery相关的文档

    http://tool.oschina.net/apidocs/apidoc?api=jquery http://www.w3school.com.cn/jquery/jquery_ref_event ...

  8. 理解Java中的final和static关键字

    回顾这两个关键字前,先考虑一个问题: Static变量存储在JVM中的位置,或者说static变量是如何被加载的? JVM会把类的静态方法和静态变量在类加载的过程中读入方法区(Method Area) ...

  9. CI重定向:php(codeigniter)中如何重定向

    Q: 在保存完数据之后需要重定向,防止数据重复提交. 我使用$this->方法名();跳转,发现不能达到重定向的效果(地址栏没变) 请教高手重定向怎么用 A: $this->load-&g ...

  10. C# 根据ADO.NET数据库连接字符串构建EntityFrame数据库连接字符串

    为了保持开发效率,以及保持代码优雅,项目中引用了EntityFrame.但是又因为某些报表功能需要大量计算,所以又要求直接使用ADO.NET,调用存储过程进行计算. 于是乎webconfig文件中就会 ...