Source Code
#include<bits/stdc++.h>
#define _for(i,n) for(int i=0;i<n;i++)
#define _forr(i,n) for(int i=1;i<=n;i++)
#define _rof(i,n) for(int i=n-1;i>=0;i--)
#define _roff(i,n) for(int i=n;i>=1;i--)
#define nl cout << "\n"
#define ff first
#define ss second
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define pb push_back
#define pp pop_back
#define vl vector<ll>
#define lsb(x) (x & ~(x-1))
#define rand(l,r) uniform_int_distribution<int>(l, r)(rng);
#define IOS ios::sync_with_stdio(0); cout.tie(0); cin.tie(0)
#define pause system("pause")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

ll const mod=1e9+7;
ll const mod1=1013;
ll const MX = 2e6+100;

ll n, a[MX], b[MX];

int main()
{
    IOS;
    ll _t=1;
//    cin>>_t;
    while(_t--)
    {
        cin>>n;
        _for(i,n)
            cin>>a[i];
        _for(i,n)
            cin>>b[i];
        cout<<(accumulate(a,a+n,n)-*min_element(a,a+n)+*min_element(b,b+n)) - (accumulate(b,b+n,n)+*min_element(b,b+n)-*min_element(a,a+n));
    }
}

/**
Test Case:
8
5 2 5  3  -30 -30 6   9
5 7 12 15 -15 -45 -39 -30
                  15  9
*/
Copy
A Game of Darts ShakerOO7
GNU G++17
16 ms
2.3 MB
Accepted