#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int n,m; cin>>n>>m;
vector<ll> a(n), b(n);
for (auto &i: a) cin>>i;
for (auto &i: b) cin>>i;
priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
for (int i=0; i<n; i++) q.push({0ll,i});
for (int j=0; j<m; j++) {
for (int i=0; i<n; i++) {
auto t=q.top(); q.pop();
if (i==t.second) {
t.first+=max(a[i],b[i]);
} else {
t.first+=b[t.second];
}
q.push(t);
}
}
cout<<q.top().first;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
412 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
205 ms |
13948 KB |
Output is correct |
12 |
Correct |
239 ms |
15044 KB |
Output is correct |
13 |
Correct |
148 ms |
13760 KB |
Output is correct |
14 |
Correct |
155 ms |
14964 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
93 ms |
14900 KB |
Output is correct |
17 |
Correct |
206 ms |
14184 KB |
Output is correct |
18 |
Correct |
198 ms |
15208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
93 ms |
14900 KB |
Output is correct |
3 |
Correct |
206 ms |
14184 KB |
Output is correct |
4 |
Correct |
198 ms |
15208 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
113 ms |
6996 KB |
Output is correct |
14 |
Correct |
81 ms |
4172 KB |
Output is correct |
15 |
Correct |
61 ms |
3764 KB |
Output is correct |
16 |
Correct |
79 ms |
2504 KB |
Output is correct |
17 |
Correct |
16 ms |
344 KB |
Output is correct |
18 |
Correct |
8 ms |
344 KB |
Output is correct |
19 |
Correct |
6 ms |
344 KB |
Output is correct |
20 |
Correct |
5 ms |
348 KB |
Output is correct |
21 |
Correct |
5 ms |
348 KB |
Output is correct |
22 |
Correct |
20 ms |
604 KB |
Output is correct |
23 |
Correct |
22 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
412 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
205 ms |
13948 KB |
Output is correct |
12 |
Correct |
239 ms |
15044 KB |
Output is correct |
13 |
Correct |
148 ms |
13760 KB |
Output is correct |
14 |
Correct |
155 ms |
14964 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
113 ms |
6996 KB |
Output is correct |
24 |
Correct |
81 ms |
4172 KB |
Output is correct |
25 |
Correct |
61 ms |
3764 KB |
Output is correct |
26 |
Correct |
79 ms |
2504 KB |
Output is correct |
27 |
Correct |
16 ms |
344 KB |
Output is correct |
28 |
Correct |
8 ms |
344 KB |
Output is correct |
29 |
Correct |
6 ms |
344 KB |
Output is correct |
30 |
Correct |
5 ms |
348 KB |
Output is correct |
31 |
Correct |
5 ms |
348 KB |
Output is correct |
32 |
Correct |
20 ms |
604 KB |
Output is correct |
33 |
Correct |
22 ms |
604 KB |
Output is correct |
34 |
Correct |
0 ms |
344 KB |
Output is correct |
35 |
Correct |
93 ms |
14900 KB |
Output is correct |
36 |
Correct |
206 ms |
14184 KB |
Output is correct |
37 |
Correct |
198 ms |
15208 KB |
Output is correct |
38 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
113 ms |
6996 KB |
Output is correct |
10 |
Correct |
81 ms |
4172 KB |
Output is correct |
11 |
Correct |
61 ms |
3764 KB |
Output is correct |
12 |
Correct |
79 ms |
2504 KB |
Output is correct |
13 |
Correct |
16 ms |
344 KB |
Output is correct |
14 |
Correct |
8 ms |
344 KB |
Output is correct |
15 |
Correct |
6 ms |
344 KB |
Output is correct |
16 |
Correct |
5 ms |
348 KB |
Output is correct |
17 |
Correct |
5 ms |
348 KB |
Output is correct |
18 |
Correct |
20 ms |
604 KB |
Output is correct |
19 |
Correct |
22 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
93 ms |
14900 KB |
Output is correct |
22 |
Correct |
206 ms |
14184 KB |
Output is correct |
23 |
Correct |
198 ms |
15208 KB |
Output is correct |
24 |
Execution timed out |
1031 ms |
2304 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
412 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
205 ms |
13948 KB |
Output is correct |
12 |
Correct |
239 ms |
15044 KB |
Output is correct |
13 |
Correct |
148 ms |
13760 KB |
Output is correct |
14 |
Correct |
155 ms |
14964 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
113 ms |
6996 KB |
Output is correct |
24 |
Correct |
81 ms |
4172 KB |
Output is correct |
25 |
Correct |
61 ms |
3764 KB |
Output is correct |
26 |
Correct |
79 ms |
2504 KB |
Output is correct |
27 |
Correct |
16 ms |
344 KB |
Output is correct |
28 |
Correct |
8 ms |
344 KB |
Output is correct |
29 |
Correct |
6 ms |
344 KB |
Output is correct |
30 |
Correct |
5 ms |
348 KB |
Output is correct |
31 |
Correct |
5 ms |
348 KB |
Output is correct |
32 |
Correct |
20 ms |
604 KB |
Output is correct |
33 |
Correct |
22 ms |
604 KB |
Output is correct |
34 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
35 |
Halted |
0 ms |
0 KB |
- |