• 个人简介

    // #include<bits/stdc++.h>
    // using namespace std;
    // int f[i];//选第i个能量球所需要的最小值
    // int main()
    // {
    
    // }
    
    #include <bits/stdc++.h>
    using namespace std;
    int n,m,a[1000005],b[1000005],c[1000005],f[1000005];
    int sum,num,minn=1e9;
    int main()
    {
        cin>>n;
        for (int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        cin>>m;
        for (int i=1;i<=m;i++)
        {
            cin>>b[i];
        }
        for (int i=1 ;i<=m;i++)
        {
            cin>>c[i];
        }
        //--------------------------------------------------------------
    
        for (int i=1 ;i<=n;i++)
        {
            for (int j=1;j<=m;j++)
            {
                if (b[j]>=a[i])
                {
                    if ((b[j]-a[i])+c[j]<minn)
                    {
                        minn=(b[j]-a[i])+c[j];
                        num=j;
                    } 
                }
            }
            if (f[num])
            {
                sum+=minn-c[num];
            }
            else
            {
                sum+=minn;
                f[num]=1;
            }
            minn=1e9;
        }
        cout<<sum;
    }
    
  • 通过的题目

  • 最近活动

    This person is lazy and didn't join any contests or homework.
  • 最近编写的题解

    This person is lazy and didn't write any solutions.