/ Randle / 题库 / 辣鸡 /

题解

1 条题解

  • 0
    @ 2017-10-02 13:55:40
    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #include<cstdlib>
    #include<algorithm>
    #define ll long long
    #define N 25003
    using namespace std;
    inline int read(int &ret)
    {
        ret=0;char ch=getchar();
        while(ch<'0'||ch>'9') ch=getchar();
        while('0'<=ch&&ch<='9')
        {
            ret=ret*10-'0'+ch;
            ch=getchar();
        }
    }
    int n,m,a[N],b[N];
    int main()
    {
        //freopen("spicychicken.in","r",stdin);
        //freopen("spicychicken.out","w",stdout);
        read(a[0]);read(b[0]);read(n);read(m);
        for(int i=n;i;--i)read(a[i]);
        sort(a,a+n+1,greater<int>());
        for(int i=0;i<=n;++i)a[i]=a[i]-a[i+1];
        sort(a,a+n+1);
        for(int i=m;i;--i)read(b[i]);
        sort(b,b+m+1,greater<int>());
        for(int i=0;i<=m;++i)b[i]=b[i]-b[i+1];
        sort(b,b+m+1);
        int p=1,q=1;
        ll ans=(ll)a[0]*m+(ll)b[0]*n;
        while(p<=n&&q<=m)
            if(a[p]<b[q])ans+=(ll)a[p++]*(m-q+1);
            else ans+=(ll)b[q++]*(n-p+1);
        printf("%lld\n",ans);
        return 0;
    }
    
  • 1

信息

难度
9
分类
(无)
标签
(无)
递交数
7
已通过
1
通过率
14%
上传者