#include<bits/stdc++.h> //Mr_Mandal
#define PI_INT 3.14159265358979323846
#define PI acos(-1.0)
#define LL long long
#define N 100000007
#define MOD 10000007
#define MX numeric_limits<long long>::max();
#define MN numeric_limits<long long>::min();
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define FILL(v, n) fill(v.begin(), v.end(), n);
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define PRINT(v) for(int i=0; i<v.size(); i++) cout<<v[i]<<" "; cout<<endl;
#define SCAN(v, n) for(int i=0; i<n; i++) { int temp; cin>>temp; v.push_back(temp); }
#define SORT(v) sort(v.rbegin(), v.rend());
#define VECT(v) vector<int>v
#define SCF(f) scanf("%d", &f)
#define PNF(f) printf("%d\n", f)
#define CASEP(v) cout<<"Case "<<c<<": "<<v<<"\n"

using namespace std;

VECT(v1); //Red apples
VECT(v2); //Green apples
VECT(v3); //Colorless apples

LL sum=0;

int x, y, a, b, c;

void solve() //Sum of all the red and green
{
    for(int i=0; i<x; i++)
        sum+=v1[i];
    for(int i=0; i<y; i++)
        sum+=v2[i];
}

void work1(int indx1, int indx3) //if green apples run out
{
    while(true)
    {
        if(indx1<0 || indx3>=v3.size())
            break;

        if(v1[indx1]<v3[indx3])
        {
            v1[indx1]=v3[indx3];

            indx1--;
            indx3++;
        }

        else break;
    }
}

void work2(int indx2, int indx3) //if red apples run out
{
    while(true)
    {
        if(indx2<0 || indx3>=v3.size())
            break;

        if(v2[indx2]<v3[indx3])
        {
            v2[indx2]=v3[indx3];

            indx2--;
            indx3++;
        }

        else break;
    }
}

int main()
{
    cin >> x >> y >> a >> b >> c;

    SCAN(v1, a);
    SCAN(v2, b);
    SCAN(v3, c);

    SORT(v1);
    SORT(v2);
    SORT(v3);

    int indx1=x-1;
    int indx2=y-1;
    int indx3=0;

    bool f1=false, f2=false, f3=false, f4=false;

    while(true)
    {
        if(indx1<0 || indx2<0 || indx3>(c-1))
        {
            if(indx1<0) //red apples run out
                f1=true;
            if(indx2<0) //green apples run out
                f2=true;
            if(indx3>(c-1)) //colorless apples run out
                f3=true;

            break;
        }

        if(min(v1[indx1], v2[indx2])<v3[indx3]) //if deliciousness is smaller than colorless apple
        {
            if(v1[indx1]>v2[indx2])
            {
                v2[indx2]=v3[indx3];

                indx2--;
                indx3++;
            }

            else
            {
                v1[indx1]=v3[indx3];

                indx1--;
                indx3++;
            }
        }

        else //No colorless apple can be choose further
        {
            f4=true;
            break;
        }
    }

    if(f4 || f3) //No colorless is valid or colorless run out
    {
        solve();
        cout<<sum<<"\n";
    }

    else if(f2) //if green runs out
    {
        work1(indx1, indx3);
        solve();
        cout<<sum<<"\n";
    }

    else if(f1) //if red runs out
    {
        work2(indx2, indx3);
        solve();
        cout<<sum<<"\n";
    }

    else //normally done
    {
        solve();
        cout<<sum<<"\n";
    }

    return 0;
}


Measured memory_bytes: 1784