Language: C++

/*input
2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4

*/

#include <bits/stdc++.h>


using namespace std;

#define ll long long





int main() {
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll p[a],q[b],r[c];
    vector<pair<ll,pair<ll,ll>>> v;
    for( ll i=0;i<a;i++)cin>>p[i];
    for( ll i=0;i<b;i++)cin>>q[i];
    for( ll i=0;i<c;i++)cin>>r[i],v.push_back({r[i],{i,3}});
    sort(p,p+a,greater<ll>());
    sort(q,q+a,greater<ll>());
    //reverse(v.begin(),v.end());
    for( ll i=0;i<x;i++)cin>>p[i],v.push_back({p[i],{i,1}});
    for( ll i=0;i<y;i++)cin>>q[i],v.push_back({q[i],{i,2}});
    sort(v.begin(),v.end(),greater<ll>());
    ll ans=0;
    for(ll i=0;i<x+y;i++){
        ll val = v[i].first;
        ll index = v[i].second.first;
        ll id = v[i].second.second;
        //cout<<val<<" ";
        ans+=val;
        
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:9:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<long long int, std::pair<long long int, long long int> >*, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<long long int, std::pair<long long int, long long int> >*, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >; _Compare = std::greater<long long int>]':
/usr/include/c++/14/bits/stl_algo.h:1777:14:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1777 |           if (__comp(__i, __first))
      |               ~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1817:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1908:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1908 |           std::__final_insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4805:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Compare = greater<long long int>]'
 4805 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:33:9:   required from here
   33 |     sort(v.begin(),v.end(),greater<ll>());
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(std::greater<long long int>) (std::pair<long long int, std::pair<long long int, long long int> >&, std::pair<long long int, std::pair<long long int, long long int> >&)'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:49,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = long long int]'
  394 |       operator()(const _Tp& __x, const _Tp& __y) const
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_function.h:394:29: note:   no known conversion for argument 1 from 'std::pair<long long int, std::pair<long long int, long long int> >' to 'const long long int&'
  394 |       operator()(const _Tp& __x, const _Tp& __y) const
      |                  ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::pair<long long int, std::pair<long long int, long long int> >; _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, std::pair<long long int, long long int> >*, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >; _Compare = std::greater<long long int>]':
/usr/include/c++/14/bits/stl_algo.h:1757:20:   required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<greater<long long int> >]'
 1757 |       while (__comp(__val, __next))
      |              ~~~~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1785:36:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1785 |             std::__unguarded_linear_insert(__i,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
 1786 |                                 __gnu_cxx::__ops::__val_comp_iter(__comp));
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1817:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1908:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
 1908 |           std::__final_insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4805:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Compare = greater<long long int>]'
 4805 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:33:9:   required from here
   33 |     sort(v.begin(),v.end(),greater<ll>());
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:240:30: error: no match for call to '(std::greater<long long int>) (std::pair<long long int, std::pair<long long int, long long int> >&, std::pair<long long int, std::pair<long long int, long long int> >&)'
  240 |         { return bool(_M_comp(__val, *__it)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = long long int]'
  394 |       operator()(const _Tp& __x, const _Tp& __y) const
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_function.h:394:29: note:   no known conversion for argument 1 from 'std::pair<long long int, std::pair<long long int, long long int> >' to 'const long long int&'
  394 |       operator()(const _Tp& __x, const _Tp& __y) const
      |                  ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, std::pair<long long int, long long int> >*, std::vector<std::pair<long long int, std::pair<long long int, long long int> > > >; _Value = std::pair<long long int, std::pair<long long int, long long int> >; _Compare = std::greater<long long int>]':
/usr/include/c++/14/bits/stl_heap.h:140:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Distance = long int; _Tp = pair<long long int, pair<long long int, long long int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_val<greater<long long int> >]'
  140 |       while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:247:23:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, pair<long long int, long long int> >*, vector<pair<long long int, pair<long long int, long long int> > > >; _Distance = long int; _Tp = pair<long long int, pair<long long int, long long int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]'
  247 |       std::__push_heap(__first, __holeIndex, __topIndex,
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248 |                        _GLIBCXX_MOVE(__value), __cmp);
      |