#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 {
return first > a.first;
}
};
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;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
4 ms |
596 KB |
Output is correct |
11 |
Correct |
208 ms |
13592 KB |
Output is correct |
12 |
Correct |
210 ms |
13484 KB |
Output is correct |
13 |
Correct |
137 ms |
13572 KB |
Output is correct |
14 |
Correct |
136 ms |
13588 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
82 ms |
13508 KB |
Output is correct |
17 |
Correct |
196 ms |
13496 KB |
Output is correct |
18 |
Correct |
209 ms |
13532 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
82 ms |
13508 KB |
Output is correct |
3 |
Correct |
196 ms |
13496 KB |
Output is correct |
4 |
Correct |
209 ms |
13532 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
308 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
120 ms |
9688 KB |
Output is correct |
14 |
Correct |
85 ms |
5864 KB |
Output is correct |
15 |
Correct |
64 ms |
5056 KB |
Output is correct |
16 |
Correct |
66 ms |
3524 KB |
Output is correct |
17 |
Correct |
13 ms |
360 KB |
Output is correct |
18 |
Correct |
9 ms |
212 KB |
Output is correct |
19 |
Correct |
6 ms |
320 KB |
Output is correct |
20 |
Correct |
4 ms |
312 KB |
Output is correct |
21 |
Correct |
5 ms |
212 KB |
Output is correct |
22 |
Correct |
14 ms |
596 KB |
Output is correct |
23 |
Correct |
16 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
4 ms |
596 KB |
Output is correct |
11 |
Correct |
208 ms |
13592 KB |
Output is correct |
12 |
Correct |
210 ms |
13484 KB |
Output is correct |
13 |
Correct |
137 ms |
13572 KB |
Output is correct |
14 |
Correct |
136 ms |
13588 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
308 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
120 ms |
9688 KB |
Output is correct |
24 |
Correct |
85 ms |
5864 KB |
Output is correct |
25 |
Correct |
64 ms |
5056 KB |
Output is correct |
26 |
Correct |
66 ms |
3524 KB |
Output is correct |
27 |
Correct |
13 ms |
360 KB |
Output is correct |
28 |
Correct |
9 ms |
212 KB |
Output is correct |
29 |
Correct |
6 ms |
320 KB |
Output is correct |
30 |
Correct |
4 ms |
312 KB |
Output is correct |
31 |
Correct |
5 ms |
212 KB |
Output is correct |
32 |
Correct |
14 ms |
596 KB |
Output is correct |
33 |
Correct |
16 ms |
596 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
82 ms |
13508 KB |
Output is correct |
36 |
Correct |
196 ms |
13496 KB |
Output is correct |
37 |
Correct |
209 ms |
13532 KB |
Output is correct |
38 |
Incorrect |
1 ms |
308 KB |
Output isn't correct |
39 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
308 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 |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
120 ms |
9688 KB |
Output is correct |
10 |
Correct |
85 ms |
5864 KB |
Output is correct |
11 |
Correct |
64 ms |
5056 KB |
Output is correct |
12 |
Correct |
66 ms |
3524 KB |
Output is correct |
13 |
Correct |
13 ms |
360 KB |
Output is correct |
14 |
Correct |
9 ms |
212 KB |
Output is correct |
15 |
Correct |
6 ms |
320 KB |
Output is correct |
16 |
Correct |
4 ms |
312 KB |
Output is correct |
17 |
Correct |
5 ms |
212 KB |
Output is correct |
18 |
Correct |
14 ms |
596 KB |
Output is correct |
19 |
Correct |
16 ms |
596 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
82 ms |
13508 KB |
Output is correct |
22 |
Correct |
196 ms |
13496 KB |
Output is correct |
23 |
Correct |
209 ms |
13532 KB |
Output is correct |
24 |
Execution timed out |
1062 ms |
3048 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 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 |
308 KB |
Output is correct |
9 |
Correct |
1 ms |
308 KB |
Output is correct |
10 |
Correct |
4 ms |
596 KB |
Output is correct |
11 |
Correct |
208 ms |
13592 KB |
Output is correct |
12 |
Correct |
210 ms |
13484 KB |
Output is correct |
13 |
Correct |
137 ms |
13572 KB |
Output is correct |
14 |
Correct |
136 ms |
13588 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
308 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
120 ms |
9688 KB |
Output is correct |
24 |
Correct |
85 ms |
5864 KB |
Output is correct |
25 |
Correct |
64 ms |
5056 KB |
Output is correct |
26 |
Correct |
66 ms |
3524 KB |
Output is correct |
27 |
Correct |
13 ms |
360 KB |
Output is correct |
28 |
Correct |
9 ms |
212 KB |
Output is correct |
29 |
Correct |
6 ms |
320 KB |
Output is correct |
30 |
Correct |
4 ms |
312 KB |
Output is correct |
31 |
Correct |
5 ms |
212 KB |
Output is correct |
32 |
Correct |
14 ms |
596 KB |
Output is correct |
33 |
Correct |
16 ms |
596 KB |
Output is correct |
34 |
Incorrect |
1 ms |
308 KB |
Output isn't correct |
35 |
Halted |
0 ms |
0 KB |
- |