# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
536777 |
2022-03-14T02:46:03 Z |
xp875 |
Self Study (JOI22_ho_t2) |
C++17 |
|
1000 ms |
12608 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, m;
cin >> n >> m;
ll a[n], b[n];
for(int i=0; i<n; i++) cin >> a[i];
for(int i=0; i<n; i++) cin >> b[i];
int c[n];
memset(c, 0, sizeof c);
if(m==1) {
ll ans = (ll)1<<60;
for(int i=0; i<n; i++) {
ans = min(ans, max(a[i], b[i]));
}
cout << ans;
}
else {
set<pair<ll, ll> > s;
for(int i=0; i<n; i++) {
s.insert(make_pair(0, i));
}
for(int i=0; i<m*n; i++) {
pair<ll, ll> p = *s.begin();
s.erase(s.find(p));
if(c[p.second]<m && a[p.second]>b[p.second]) {
p.first += a[p.second];
c[p.second]++;
}
else p.first += b[p.second];
s.insert(p);
}
//for(auto p : s) cout << p.first << ' ';
cout << s.begin()->first;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 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 |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
217 ms |
6120 KB |
Output is correct |
12 |
Correct |
229 ms |
6120 KB |
Output is correct |
13 |
Correct |
181 ms |
6120 KB |
Output is correct |
14 |
Correct |
154 ms |
6132 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
85 ms |
6120 KB |
Output is correct |
17 |
Correct |
253 ms |
6120 KB |
Output is correct |
18 |
Correct |
228 ms |
6124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
85 ms |
6120 KB |
Output is correct |
3 |
Correct |
253 ms |
6120 KB |
Output is correct |
4 |
Correct |
228 ms |
6124 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 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 |
256 ms |
12608 KB |
Output is correct |
14 |
Correct |
207 ms |
8380 KB |
Output is correct |
15 |
Correct |
170 ms |
6436 KB |
Output is correct |
16 |
Correct |
152 ms |
5192 KB |
Output is correct |
17 |
Correct |
35 ms |
340 KB |
Output is correct |
18 |
Correct |
26 ms |
272 KB |
Output is correct |
19 |
Correct |
20 ms |
292 KB |
Output is correct |
20 |
Correct |
12 ms |
212 KB |
Output is correct |
21 |
Correct |
13 ms |
292 KB |
Output is correct |
22 |
Correct |
58 ms |
668 KB |
Output is correct |
23 |
Correct |
61 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 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 |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
217 ms |
6120 KB |
Output is correct |
12 |
Correct |
229 ms |
6120 KB |
Output is correct |
13 |
Correct |
181 ms |
6120 KB |
Output is correct |
14 |
Correct |
154 ms |
6132 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 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 |
256 ms |
12608 KB |
Output is correct |
24 |
Correct |
207 ms |
8380 KB |
Output is correct |
25 |
Correct |
170 ms |
6436 KB |
Output is correct |
26 |
Correct |
152 ms |
5192 KB |
Output is correct |
27 |
Correct |
35 ms |
340 KB |
Output is correct |
28 |
Correct |
26 ms |
272 KB |
Output is correct |
29 |
Correct |
20 ms |
292 KB |
Output is correct |
30 |
Correct |
12 ms |
212 KB |
Output is correct |
31 |
Correct |
13 ms |
292 KB |
Output is correct |
32 |
Correct |
58 ms |
668 KB |
Output is correct |
33 |
Correct |
61 ms |
620 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
85 ms |
6120 KB |
Output is correct |
36 |
Correct |
253 ms |
6120 KB |
Output is correct |
37 |
Correct |
228 ms |
6124 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
212 KB |
Output is correct |
40 |
Correct |
0 ms |
212 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
0 ms |
212 KB |
Output is correct |
43 |
Correct |
0 ms |
212 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
54 ms |
684 KB |
Output is correct |
46 |
Correct |
20 ms |
948 KB |
Output is correct |
47 |
Correct |
10 ms |
340 KB |
Output is correct |
48 |
Correct |
86 ms |
4492 KB |
Output is correct |
49 |
Correct |
2 ms |
212 KB |
Output is correct |
50 |
Correct |
45 ms |
212 KB |
Output is correct |
51 |
Correct |
63 ms |
664 KB |
Output is correct |
52 |
Correct |
12 ms |
212 KB |
Output is correct |
53 |
Correct |
41 ms |
280 KB |
Output is correct |
54 |
Correct |
42 ms |
212 KB |
Output is correct |
55 |
Correct |
273 ms |
12456 KB |
Output is correct |
56 |
Correct |
183 ms |
8524 KB |
Output is correct |
57 |
Correct |
156 ms |
8492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 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 |
256 ms |
12608 KB |
Output is correct |
10 |
Correct |
207 ms |
8380 KB |
Output is correct |
11 |
Correct |
170 ms |
6436 KB |
Output is correct |
12 |
Correct |
152 ms |
5192 KB |
Output is correct |
13 |
Correct |
35 ms |
340 KB |
Output is correct |
14 |
Correct |
26 ms |
272 KB |
Output is correct |
15 |
Correct |
20 ms |
292 KB |
Output is correct |
16 |
Correct |
12 ms |
212 KB |
Output is correct |
17 |
Correct |
13 ms |
292 KB |
Output is correct |
18 |
Correct |
58 ms |
668 KB |
Output is correct |
19 |
Correct |
61 ms |
620 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
85 ms |
6120 KB |
Output is correct |
22 |
Correct |
253 ms |
6120 KB |
Output is correct |
23 |
Correct |
228 ms |
6124 KB |
Output is correct |
24 |
Execution timed out |
1085 ms |
3952 KB |
Time limit exceeded |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 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 |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
217 ms |
6120 KB |
Output is correct |
12 |
Correct |
229 ms |
6120 KB |
Output is correct |
13 |
Correct |
181 ms |
6120 KB |
Output is correct |
14 |
Correct |
154 ms |
6132 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
0 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 |
256 ms |
12608 KB |
Output is correct |
24 |
Correct |
207 ms |
8380 KB |
Output is correct |
25 |
Correct |
170 ms |
6436 KB |
Output is correct |
26 |
Correct |
152 ms |
5192 KB |
Output is correct |
27 |
Correct |
35 ms |
340 KB |
Output is correct |
28 |
Correct |
26 ms |
272 KB |
Output is correct |
29 |
Correct |
20 ms |
292 KB |
Output is correct |
30 |
Correct |
12 ms |
212 KB |
Output is correct |
31 |
Correct |
13 ms |
292 KB |
Output is correct |
32 |
Correct |
58 ms |
668 KB |
Output is correct |
33 |
Correct |
61 ms |
620 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
0 ms |
212 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
0 ms |
212 KB |
Output is correct |
39 |
Correct |
0 ms |
212 KB |
Output is correct |
40 |
Correct |
0 ms |
212 KB |
Output is correct |
41 |
Correct |
54 ms |
684 KB |
Output is correct |
42 |
Correct |
20 ms |
948 KB |
Output is correct |
43 |
Correct |
10 ms |
340 KB |
Output is correct |
44 |
Correct |
86 ms |
4492 KB |
Output is correct |
45 |
Correct |
2 ms |
212 KB |
Output is correct |
46 |
Correct |
45 ms |
212 KB |
Output is correct |
47 |
Correct |
63 ms |
664 KB |
Output is correct |
48 |
Correct |
12 ms |
212 KB |
Output is correct |
49 |
Correct |
41 ms |
280 KB |
Output is correct |
50 |
Correct |
42 ms |
212 KB |
Output is correct |
51 |
Correct |
273 ms |
12456 KB |
Output is correct |
52 |
Correct |
183 ms |
8524 KB |
Output is correct |
53 |
Correct |
156 ms |
8492 KB |
Output is correct |
54 |
Execution timed out |
1085 ms |
3952 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |