标签:
# include<iostream> # include<cstdio> # include<cstring> # include<vector> # include<map> # include<set> # include<list> # include<cstdlib> # include<string> # include<iomanip> # include<algorithm> using namespace std; # define LL long double struct arr { LL val; int id; arr(){} arr(LL a,int b):val(a),id(b){} bool operator < (const arr& a) const { return val<a.val; } }; arr w1[500005],w2[500005]; int main() { int T,a,b,n,cas=0; scanf("%d",&T); while(T--) { int k; scanf("%d%d%d",&n,&a,&b); for(int i=0;i<n;++i){ scanf("%d",&k); w1[i]=arr((LL)a*(LL)k*(LL)k,i); w2[i]=arr((LL)b*(LL)k,i); } sort(w1,w1+n); sort(w2,w2+n); printf("Case #%d: ",++cas); if(w1[n-1].id!=w2[n-1].id) cout<<fixed<<setprecision(0)<<w1[n-1].val+w2[n-1].val<<endl; else{ LL ans1=w1[n-1].val+w2[n-2].val; LL ans2=w1[n-2].val+w2[n-1].val; cout<<fixed<<setprecision(0)<<max(ans1,ans2)<<endl; } } return 0; }
标签:
原文地址:http://www.cnblogs.com/20143605--pcx/p/4822897.html