#include <iostream>
#include <queue>
#define int long long
using namespace std;
const int nmax = 3e5 + 7;
int v[nmax], b[nmax];
struct pairing {
int first, second;
const bool operator < (pairing a) const {
if(first != a.first) {
return first > a.first;
} else {
return second > a.second;
}
}
};
int32_t main() {
int n, k;
cin >> n >> k;
for(int i = 1; i <= n; i ++) {
cin >> v[i];
}
for(int i = 1; i <= n; i ++){
cin >> b[i];
}
priority_queue<pairing> pq;
for(int i = 1; i <= n; i ++) {
pq.push({max(v[i], b[i]), i});
}
for(int i = 2; i <= k; i ++) {
for(int j = 1; j <= n; j ++) {
int sum = pq.top().first, ind = pq.top().second;
pq.pop();
if(j == ind) {
sum += max(v[j], b[j]);
} else {
sum += b[ind];
}
pq.push({sum, ind});
}
}
int minn = 1e18;
while(!pq.empty()) {
minn = min(minn, pq.top().first);
pq.pop();
}
cout << minn;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
596 KB |
Output is correct |
11 |
Correct |
206 ms |
13568 KB |
Output is correct |
12 |
Correct |
211 ms |
13496 KB |
Output is correct |
13 |
Correct |
148 ms |
13556 KB |
Output is correct |
14 |
Correct |
148 ms |
13556 KB |
Output is correct |
15 |
Correct |
1 ms |
304 KB |
Output is correct |
16 |
Correct |
91 ms |
13540 KB |
Output is correct |
17 |
Correct |
198 ms |
13564 KB |
Output is correct |
18 |
Correct |
224 ms |
13524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
91 ms |
13540 KB |
Output is correct |
3 |
Correct |
198 ms |
13564 KB |
Output is correct |
4 |
Correct |
224 ms |
13524 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
119 ms |
7196 KB |
Output is correct |
14 |
Correct |
99 ms |
4364 KB |
Output is correct |
15 |
Correct |
70 ms |
3980 KB |
Output is correct |
16 |
Correct |
68 ms |
2680 KB |
Output is correct |
17 |
Correct |
21 ms |
360 KB |
Output is correct |
18 |
Correct |
9 ms |
212 KB |
Output is correct |
19 |
Correct |
6 ms |
212 KB |
Output is correct |
20 |
Correct |
5 ms |
308 KB |
Output is correct |
21 |
Correct |
5 ms |
212 KB |
Output is correct |
22 |
Correct |
19 ms |
596 KB |
Output is correct |
23 |
Correct |
24 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
596 KB |
Output is correct |
11 |
Correct |
206 ms |
13568 KB |
Output is correct |
12 |
Correct |
211 ms |
13496 KB |
Output is correct |
13 |
Correct |
148 ms |
13556 KB |
Output is correct |
14 |
Correct |
148 ms |
13556 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
304 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
119 ms |
7196 KB |
Output is correct |
24 |
Correct |
99 ms |
4364 KB |
Output is correct |
25 |
Correct |
70 ms |
3980 KB |
Output is correct |
26 |
Correct |
68 ms |
2680 KB |
Output is correct |
27 |
Correct |
21 ms |
360 KB |
Output is correct |
28 |
Correct |
9 ms |
212 KB |
Output is correct |
29 |
Correct |
6 ms |
212 KB |
Output is correct |
30 |
Correct |
5 ms |
308 KB |
Output is correct |
31 |
Correct |
5 ms |
212 KB |
Output is correct |
32 |
Correct |
19 ms |
596 KB |
Output is correct |
33 |
Correct |
24 ms |
596 KB |
Output is correct |
34 |
Correct |
1 ms |
304 KB |
Output is correct |
35 |
Correct |
91 ms |
13540 KB |
Output is correct |
36 |
Correct |
198 ms |
13564 KB |
Output is correct |
37 |
Correct |
224 ms |
13524 KB |
Output is correct |
38 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
119 ms |
7196 KB |
Output is correct |
10 |
Correct |
99 ms |
4364 KB |
Output is correct |
11 |
Correct |
70 ms |
3980 KB |
Output is correct |
12 |
Correct |
68 ms |
2680 KB |
Output is correct |
13 |
Correct |
21 ms |
360 KB |
Output is correct |
14 |
Correct |
9 ms |
212 KB |
Output is correct |
15 |
Correct |
6 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
308 KB |
Output is correct |
17 |
Correct |
5 ms |
212 KB |
Output is correct |
18 |
Correct |
19 ms |
596 KB |
Output is correct |
19 |
Correct |
24 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
304 KB |
Output is correct |
21 |
Correct |
91 ms |
13540 KB |
Output is correct |
22 |
Correct |
198 ms |
13564 KB |
Output is correct |
23 |
Correct |
224 ms |
13524 KB |
Output is correct |
24 |
Execution timed out |
1065 ms |
2448 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
308 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
596 KB |
Output is correct |
11 |
Correct |
206 ms |
13568 KB |
Output is correct |
12 |
Correct |
211 ms |
13496 KB |
Output is correct |
13 |
Correct |
148 ms |
13556 KB |
Output is correct |
14 |
Correct |
148 ms |
13556 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
304 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
119 ms |
7196 KB |
Output is correct |
24 |
Correct |
99 ms |
4364 KB |
Output is correct |
25 |
Correct |
70 ms |
3980 KB |
Output is correct |
26 |
Correct |
68 ms |
2680 KB |
Output is correct |
27 |
Correct |
21 ms |
360 KB |
Output is correct |
28 |
Correct |
9 ms |
212 KB |
Output is correct |
29 |
Correct |
6 ms |
212 KB |
Output is correct |
30 |
Correct |
5 ms |
308 KB |
Output is correct |
31 |
Correct |
5 ms |
212 KB |
Output is correct |
32 |
Correct |
19 ms |
596 KB |
Output is correct |
33 |
Correct |
24 ms |
596 KB |
Output is correct |
34 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
35 |
Halted |
0 ms |
0 KB |
- |