1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
void mySort(vector<int> &inp)
{
sort(inp.begin(), inp.end());
reverse(inp.begin(), inp.end());
}
int main()
{
int x, y, a, b, c;
scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
vector<int> red, green, cand;
for (int i = 0; i < a; i++) {
int num;
scanf("%d", &num);
red.push_back(num);
}
for (int i = 0; i < b; i++) {
int num;
scanf("%d", &num);
green.push_back(num);
}
for (int i = 0; i < c; i++) {
int num;
scanf("%d", &num);
cand.push_back(num);
}
mySort(red);
mySort(green);
mySort(cand);
vector<int> orig;
for (int i = 0; i < x; i++)
orig.push_back(red[i]);
for (int i = 0; i < y; i++)
orig.push_back(green[i]);
mySort(orig);
int j = 0;
for (int i = x + y - 1; i >= 0 && j < c; i--) {
if (cand[j] > orig[i]) {
orig[i] = cand[j];
j++;
}
}
ll ans = 0;
for (int i = 0; i < x + y; i++)
ans += orig[i];
printf("%lld\n", ans);
return 0;
}
|