-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTADELIVE.cpp
54 lines (51 loc) · 1.08 KB
/
TADELIVE.cpp
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
#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
vector<pair<int, int>> d;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n, x, y, i, ans = 0;
cin >> n >> x >> y;
for (i = 0; i < n; i++)
cin >> a[i];
for (i = 0; i < n; i++)
cin >> b[i];
for (i = 0; i < n; i++)
d.push_back(make_pair(abs(a[i] - b[i]), i));
sort(d.begin(), d.end(), greater<pair<int, int>>());
for (i = 0; i < n; i++)
{
if (a[d[i].second] > b[d[i].second])
{
if (x)
{
ans += a[d[i].second];
x--;
}
else
{
ans += b[d[i].second];
y--;
}
}
else
{
if (y)
{
ans += b[d[i].second];
y--;
}
else
{
ans += a[d[i].second];
x--;
}
}
}
cout << ans;
return 0;
}