#include <iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<map>#include<Set>#include<vector>#include<cmath>#defineINF 0x3f3f3f3f3f3f3f3fusing namespacestd;intt,t[5001000];intMain () {intcas=0, T1,t2; scanf ("%d",&T); while(t--) { Long Longans11=-inf,ans12=-inf,ans21=-inf,ans22=-inf; CAS+=1; intn,a,b; Long Longans=0; scanf ("%d%d%d",&n,&a,&b); for(intI=1; i<=n; i++) {scanf ("%d",&T[i]); } for(intI=1; i<=n; i++) { if(1ll*a*t[i]*t[i]>ANS11) {ANS11=1ll*a*t[i]*T[i]; T1=i; } } for(intI=1; i<=n; i++) { if(1ll*a*t[i]*t[i]>=ans12&&1ll*a*t[i]*t[i]<=ans11&&i!=t1) ans12=1ll*a*t[i]*T[i]; } for(intj=1; j<=n; J + +) { if(1ll*b*t[j]>ANS21) {ANS21=1ll*b*T[j]; T2=J; } } for(intj=1; j<=n; J + +) { if(1ll*b*t[j]>=ans22&&1ll*b*t[j]<=ans21&&j!=T2) Ans22=1ll*b*T[j]; } if(a!=0&&b!=0) { if(t1==T2) {ans=max (ans11+ans22,ans12+ANS21); } Elseans=ans11+Ans21; } Elseans=ans11+Ans21; cout<<"Case #"<<cas<<": "<<ans<<Endl; } return 0;}
Water problem .... But the brain short-circuit write time is not short. The idea is to find the biggest and second largest a*t[i]*t[i] and B*t[j], and then judge can
2015 Shenyang Tournament Online tournament 1012 (water)