-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbee1802.cpp
More file actions
45 lines (35 loc) · 805 Bytes
/
Copy pathbee1802.cpp
File metadata and controls
45 lines (35 loc) · 805 Bytes
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
/*
* Contest : Beecrowd
* Problem : 1802 - Catálogo de Livros
* Link : https://judge.beecrowd.com/pt/problems/view/1802
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int main() {
fastio
auto read = [](vector<ll> &v) {
int n; cin >> n;
v.resize(n);
for (auto &i : v) cin >> i;
};
vector<ll> p, m, f, q, b;
read(p);
read(m);
read(f);
read(q);
read(b);
int k; cin >> k;
vector<ll> all;
for (auto &pi : p)
for (auto &mi : m)
for (auto &fi : f)
for (auto &qi : q)
for (auto &bi : b) all.push_back(pi + mi + fi + qi + bi);
sort(all.rbegin(), all.rend());
ll sum = 0;
for (int i = 0; i < k; ++i) sum += all[i];
cout << sum << '\n';
return 0;
}