-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP15720.cpp
49 lines (37 loc) · 1.04 KB
/
P15720.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
#include <iostream>
#include <algorithm>
using namespace std;
int Barr[10001] = {};
int Carr[10001] = {};
int Darr[10001] = {};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int B, C, D;
cin >> B >> C >> D;
int minAmount = min(B, min(C, D));
int total = 0;
for (int i = 0; i < B; i++) {
cin >> Barr[i];
total += Barr[i];
}
for (int i = 0; i < C; i++) {
cin >> Carr[i];
total += Carr[i];
}
for (int i = 0; i < D; i++) {
cin >> Darr[i];
total += Darr[i];
}
sort(Barr, Barr + B, greater<int>());
sort(Carr, Carr + C, greater<int>());
sort(Darr, Darr + D, greater<int>());
int result = 0;
for (int i = 0; i < minAmount; i++) result += (Barr[i] + Carr[i] + Darr[i]) * 0.9;
for (int i = minAmount; i < B; i++) result += Barr[i];
for (int i = minAmount; i < C; i++) result += Carr[i];
for (int i = minAmount; i < D; i++) result += Darr[i];
cout << total << "\n" << result;
return 0;
}