hdu 5461 Largest Point
来源:互联网 发布:chart.js 更新数据 编辑:程序博客网 时间:2024/05/16 23:55
Problem Description
Given the sequence A with n integers t1,t2,⋯,tn. Given the integral coefficients a and b. The fact that select two elements ti and tj of A and i≠j to maximize the value of at2i+btj, becomes the largest point.
Input
An positive integer T, indicating there are T test cases.
For each test case, the first line contains three integers corresponding to n (2≤n≤5×106), a (0≤|a|≤106) and b (0≤|b|≤106). The second line contains n integers t1,t2,⋯,tn where 0≤|ti|≤106 for 1≤i≤n.
The sum of n for all cases would not be larger than 5×106.
Output
The output contains exactly T lines.
For each test case, you should output the maximum value of at2i+btj.
Sample Input
2
3 2 1
1 2 3
5 -1 0
-3 -3 0 3 3
Sample Output
Case #1: 20
Case #2: 0
Source
2015 ACM/ICPC Asia Regional Shenyang Online
Recommend
wange2014
#include<stdio.h>#include<algorithm>#include<string.h>#include<bits/stdc++.h>#define ll long longusing namespace std;struct nana{ long long m,n;}A[500010],B[500010];int cmp(nana a,nana b){ return a.m<b.m;}int main(){ int T; ll flag=0; scanf("%d",&T); while(T--) { ll n,a,b,t; scanf("%lld%lld%lld",&n,&a,&b); for(ll i=0;i<n;i++) { scanf("%lld",&t); A[i].m=a*t*t; A[i].n=i; B[i].m=b*t; B[i].n=i; } sort(A,A+n,cmp); sort(B,B+n,cmp); printf("Case #%lld: %lld\n",++flag,(A[n-1].n==B[n-1].n)?(max(A[n-1].m+B[n-2].m,A[n-2].m+B[n-1].m)):(A[n-1].m+B[n-1].m)); } return 0;}
- hdu 5461 Largest Point
- HDU 5461 Largest Point
- hdu 5461 Largest Point
- HDU 5461Largest Point
- HDU-5461 Largest Point
- hdu 5461 Largest Point
- HDU 5461:Largest Point
- hdu 5461 Largest Point
- HDU 5461 Largest Point
- hdu 5461 Largest Point
- HDU 5461 Largest Point
- hdu 5461 Largest Point
- HDU 5461 Largest Point (水题)
- hdu 5461 Largest Point(水)
- hdu 5461 Largest Point 【贪心】
- HDU 5461 Largest Point 水题
- HDU 5461 Largest Point (水)
- hdu 5461 Largest Point(暴搞)
- 算法训练 求先序排列
- An Invitation to Algebraic Geometry
- 高内聚与低耦合
- 工程管理器及makefile模板的使用
- 陆源:阿贝尔对椭圆函数论的贡献[附椭圆函数、模形式(g_2,g_3)、模函数的C++程序计算]
- hdu 5461 Largest Point
- 前端自动化神器-gulp
- 小白心路历程
- hdu 5949 Relative atomic mass
- 加法定理的纯分析证明;周期性的纯分析证明
- “补码”的数学原理
- ZCMU--1825-分解质因数
- 监听SD卡的状态
- 继承与派生--单一继承