【BZOJ】3850: ZCC Loves Codefires(300T就这样献给了水题TAT)

http://www.lydsy.com/JudgeOnline/problem.php?id=3850

题意:类似国王游戏....无意义..

#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; static 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就这样献给了这种水题TAT..

你可能感兴趣的:(code)