1 | |
2 | #include<bits/stdc++.h> |
3 | using namespace std; |
4 | const long long N=3e5+10; |
5 | long long n,m,x,y,z; |
6 | struct node |
7 | { |
8 | long long num; |
9 | int type; |
10 | }; |
11 | node a[N]; |
12 | bool cmp(node x,node y) |
13 | { |
14 | return x.num>y.num; |
15 | } |
16 | long long cnt1,cnt2,ans; |
17 | int main() |
18 | { |
19 | cin>>n>>m>>x>>y>>z; |
20 | for(long long i=1;i<=x;i++) |
21 | { |
22 | cin>>a[i].num; |
23 | a[i].type=1; |
24 | } |
25 | for(long long i=1;i<=y;i++) |
26 | { |
27 | cin>>a[x+i].num; |
28 | a[x+i].type=2; |
29 | } |
30 | for(long long i=1;i<=z;i++) |
31 | { |
32 | cin>>a[x+y+i].num; |
33 | a[x+y+i].type=3; |
34 | } |
35 | sort(a+1,a+1+x+y+z,cmp); |
36 | |
37 | |
38 | |
39 | |
40 | long long i=1; |
41 | while((cnt1<n||cnt2<m)&&i<=x+y+z) |
42 | { |
43 | if(a[i].type==1) |
44 | { |
45 | if(cnt1<n) |
46 | { |
47 | cnt1++; |
48 | ans+=a[i].num; |
49 | } |
50 | } |
51 | else if(a[i].type==2) |
52 | { |
53 | if(cnt2<m) |
54 | { |
55 | cnt2++; |
56 | ans+=a[i].num; |
57 | } |
58 | } |
59 | else |
60 | { |
61 | if(cnt1<n) |
62 | { |
63 | cnt1++; |
64 | ans+=a[i].num; |
65 | } |
66 | else if(cnt2<m) |
67 | { |
68 | cnt2++; |
69 | ans+=a[i].num; |
70 | } |
71 | } |
72 | i++; |
73 | } |
74 | cout<<ans; |
75 | return 0; |
76 | } |