贪心,按Ei/Ki从小到大排序
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct ti
{
double tim;
double lose;
double value;
}a[1000005];
int cmp(ti x,ti y)
{
return x.value<y.value;
}
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
scanf("%lf",&a[i].tim);
for(int i=1;i<=n;i++)
{
scanf("%lf",&a[i].lose);
a[i].value=a[i].tim/a[i].lose;
}
sort(a+1,a+n+1,cmp);
int tot=0;long long ans=0;
for(int i=1;i<=n;i++)
{
tot+=a[i].tim;
ans+=tot*a[i].lose;
//cout<<ans<<" ";
}
cout<<ans;
}