#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++) {
vector<int> days(n,0);
for (int i=0; i<n; i++) {
auto t=q.top(); q.pop();
if (days[t.second]==0) {
t.first+=max(a[t.second],b[t.second]);
days[t.second]=1;
} else {
t.first+=b[t.second];
}
q.push(t);
}
}
cout<<q.top().first;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
196 ms |
15296 KB |
Output is correct |
12 |
Correct |
189 ms |
14272 KB |
Output is correct |
13 |
Correct |
147 ms |
14440 KB |
Output is correct |
14 |
Correct |
146 ms |
14524 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
91 ms |
14448 KB |
Output is correct |
17 |
Correct |
216 ms |
13760 KB |
Output is correct |
18 |
Correct |
193 ms |
13760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
91 ms |
14448 KB |
Output is correct |
3 |
Correct |
216 ms |
13760 KB |
Output is correct |
4 |
Correct |
193 ms |
13760 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 |
344 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 |
6984 KB |
Output is correct |
14 |
Correct |
95 ms |
4156 KB |
Output is correct |
15 |
Correct |
72 ms |
3780 KB |
Output is correct |
16 |
Correct |
66 ms |
2528 KB |
Output is correct |
17 |
Correct |
14 ms |
348 KB |
Output is correct |
18 |
Correct |
11 ms |
432 KB |
Output is correct |
19 |
Correct |
7 ms |
348 KB |
Output is correct |
20 |
Correct |
7 ms |
428 KB |
Output is correct |
21 |
Correct |
7 ms |
348 KB |
Output is correct |
22 |
Correct |
20 ms |
644 KB |
Output is correct |
23 |
Correct |
22 ms |
600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
196 ms |
15296 KB |
Output is correct |
12 |
Correct |
189 ms |
14272 KB |
Output is correct |
13 |
Correct |
147 ms |
14440 KB |
Output is correct |
14 |
Correct |
146 ms |
14524 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
344 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 |
6984 KB |
Output is correct |
24 |
Correct |
95 ms |
4156 KB |
Output is correct |
25 |
Correct |
72 ms |
3780 KB |
Output is correct |
26 |
Correct |
66 ms |
2528 KB |
Output is correct |
27 |
Correct |
14 ms |
348 KB |
Output is correct |
28 |
Correct |
11 ms |
432 KB |
Output is correct |
29 |
Correct |
7 ms |
348 KB |
Output is correct |
30 |
Correct |
7 ms |
428 KB |
Output is correct |
31 |
Correct |
7 ms |
348 KB |
Output is correct |
32 |
Correct |
20 ms |
644 KB |
Output is correct |
33 |
Correct |
22 ms |
600 KB |
Output is correct |
34 |
Correct |
0 ms |
344 KB |
Output is correct |
35 |
Correct |
91 ms |
14448 KB |
Output is correct |
36 |
Correct |
216 ms |
13760 KB |
Output is correct |
37 |
Correct |
193 ms |
13760 KB |
Output is correct |
38 |
Correct |
1 ms |
600 KB |
Output is correct |
39 |
Correct |
0 ms |
344 KB |
Output is correct |
40 |
Correct |
1 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
1 ms |
412 KB |
Output is correct |
44 |
Correct |
0 ms |
344 KB |
Output is correct |
45 |
Correct |
23 ms |
752 KB |
Output is correct |
46 |
Incorrect |
8 ms |
1116 KB |
Output isn't correct |
47 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 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 |
6984 KB |
Output is correct |
10 |
Correct |
95 ms |
4156 KB |
Output is correct |
11 |
Correct |
72 ms |
3780 KB |
Output is correct |
12 |
Correct |
66 ms |
2528 KB |
Output is correct |
13 |
Correct |
14 ms |
348 KB |
Output is correct |
14 |
Correct |
11 ms |
432 KB |
Output is correct |
15 |
Correct |
7 ms |
348 KB |
Output is correct |
16 |
Correct |
7 ms |
428 KB |
Output is correct |
17 |
Correct |
7 ms |
348 KB |
Output is correct |
18 |
Correct |
20 ms |
644 KB |
Output is correct |
19 |
Correct |
22 ms |
600 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
91 ms |
14448 KB |
Output is correct |
22 |
Correct |
216 ms |
13760 KB |
Output is correct |
23 |
Correct |
193 ms |
13760 KB |
Output is correct |
24 |
Execution timed out |
1035 ms |
2260 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 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 |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
604 KB |
Output is correct |
11 |
Correct |
196 ms |
15296 KB |
Output is correct |
12 |
Correct |
189 ms |
14272 KB |
Output is correct |
13 |
Correct |
147 ms |
14440 KB |
Output is correct |
14 |
Correct |
146 ms |
14524 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
344 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 |
6984 KB |
Output is correct |
24 |
Correct |
95 ms |
4156 KB |
Output is correct |
25 |
Correct |
72 ms |
3780 KB |
Output is correct |
26 |
Correct |
66 ms |
2528 KB |
Output is correct |
27 |
Correct |
14 ms |
348 KB |
Output is correct |
28 |
Correct |
11 ms |
432 KB |
Output is correct |
29 |
Correct |
7 ms |
348 KB |
Output is correct |
30 |
Correct |
7 ms |
428 KB |
Output is correct |
31 |
Correct |
7 ms |
348 KB |
Output is correct |
32 |
Correct |
20 ms |
644 KB |
Output is correct |
33 |
Correct |
22 ms |
600 KB |
Output is correct |
34 |
Correct |
1 ms |
600 KB |
Output is correct |
35 |
Correct |
0 ms |
344 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
1 ms |
412 KB |
Output is correct |
40 |
Correct |
0 ms |
344 KB |
Output is correct |
41 |
Correct |
23 ms |
752 KB |
Output is correct |
42 |
Incorrect |
8 ms |
1116 KB |
Output isn't correct |
43 |
Halted |
0 ms |
0 KB |
- |