# include<stdio.h>
# include <algorithm>
# include <string.h>
using namespace std;
struct node
{
    int v;
    int t;
};
struct node a[100010];
bool cmp(node a,node b)
{
    return  a.v *a.t+(a.v+b.v)*b.t<b.v*b.t+(a.v+b.v)*a.t;
}
int main()
{
    int n;
    __int64 sum;
    int i;
    while(~scanf("%d",&n))
    {
        
        for(i=0;i<n;i++)
            scanf("%d",&a[i].v);
        for(i=0;i<n;i++)
            scanf("%d",&a[i].t);
        sort(a,a+n,cmp);
        __int64 sum1=0;
        sum=0;
        for(i=0;i<n;i++)
        {
            sum = (a[i].v+sum);
            sum1+=sum*a[i].t;
        }
        printf("%I64d\n",sum1);
    }
    return 0;
}

posted on 2017-06-24 21:17  yutingliuyl  阅读(170)  评论(0编辑  收藏  举报