http://www.lydsy.com/JudgeOnline/problem.php?id=3850
Test instructions: Like King game .... No meaning.
#include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream > #include <algorithm> #include <queue> #include <set> #include <map> #include <sstream >using namespace Std;typedef long long ll; #define PB Push_back#define Rep (i, n) for (int i=0; i< (n); ++i) #define For1 (i,a,n) for (int i= (a), i<= (n), ++i) #define FOR2 (i,a,n) for (int i= (a);i< (n), ++i) #define FOR3 (i,a,n) for (int i= (a); I >= (n); i) #define FOR4 (i,a,n) for (int i= (a);i> (n); i) #define CC (i,a) memset (i,a,sizeof (i)) #define READ (a) a= Getint () #define PRINT (a) printf ("%d", a) #define DBG (x) cout << (#x) << "=" << (x) << Endl#define Error (x) (! ( x) puts ("error"): 0) #define RDM (x, i) for (int i=ihead[x]; i; i=e[i].next) inline int getint () {static int r, K; r=0,k=1; St Atic Char C; C=getchar (); for (; c< ' 0 ' | | C> ' 9 '; C=getchar ()) if (c== '-') k=-1; for (; c>= ' 0 ' &&c<= ' 9 '; C=getchar ()) r=r*10+c-' 0 '; return k*r; }const int n=1e5+10;struct dat {int x, y;} A[n];ll ans;int n;bool cmp (const dat &a, const dat &b) {return a.y*a.x+b.y* (a.x+b.x) <b.y*b.x+a.y* (a.x+b.x);} int main () {read (n); Rep (i, N) read (a[i].x); Rep (i, N) read (A[I].Y); sort (A, a+n, CMP); ll Sum=0;rep (i, N) sum+=a[i].x, ans+= Sum*a[i].y;cout << Ans;return 0;}
300T is dedicated to this water-problem tat.
"Bzoj" 3850:ZCC Loves codefires (300T is dedicated to water title tat)