考虑a排在b前边的条件
at*bv<bt*av
即at/av<bt/bv
排序即可
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<stack>
using namespace std;
#define MAXN 100010
#define MAXM 1010
#define INF 1000000000
#define MOD 1000000007
#define eps 1e-8
#define ll long long
struct zcc{
int x;
int y;
double k;
friend bool operator <(zcc x,zcc y){
return x.k<y.k;
}
};
int n;
zcc a[MAXN];
ll ans;
ll now;
int main(){
int i;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&a[i].x);
}
for(i=1;i<=n;i++){
scanf("%d",&a[i].y);
a[i].k=1.0*a[i].x/a[i].y;
}
sort(a+1,a+n+1);
for(i=1;i<=n;i++){
now+=a[i].x;
ans+=now*a[i].y;
}
printf("%lld\n",ans);
return 0;
}
/*
*/