新年多水水^_^
话说这题逗我。。。国王游戏还不用高精←_←
1 /************************************************************** 2 Problem: 3850 3 User: rausen 4 Language: C++ 5 Result: Accepted 6 Time:56 ms 7 Memory:1588 kb 8 ****************************************************************/ 9 10 #include <cstdio> 11 #include <algorithm> 12 13 using namespace std; 14 typedef long long ll; 15 const int N = 1e5 + 5; 16 17 struct data { 18 int x, y; 19 20 inline bool operator < (const data &a) const { 21 return a.y * x < y * a.x; 22 } 23 } a[N]; 24 25 int n; 26 ll s, ans; 27 28 int main() { 29 int i; 30 scanf("%d", &n); 31 for (i = 1; i <= n; ++i) 32 scanf("%d", &a[i].x); 33 for (i = 1; i <= n; ++i) 34 scanf("%d", &a[i].y); 35 sort(a + 1, a + n + 1); 36 for (i = 1; i <= n; ++i) 37 s += a[i].x, ans += 1ll * s * a[i].y; 38 printf("%lld ", ans); 39 return 0; 40 }