# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
681678 |
2023-01-13T16:45:14 Z |
dsyz |
Self Study (JOI22_ho_t2) |
C++17 |
|
273 ms |
13244 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (300005)
ll N,M;
ll A[MAXN], B[MAXN];
bool bs(ll mid){
ll extra = 0;
ll arr[N];
bool done[N];
memset(done,0,sizeof(done));
for(ll i = 0;i < N;i++){
arr[i] = mid;
}
for(ll i = 0;i < N;i++){
ll minimum = mid / A[i];
if(minimum * A[i] < mid) minimum++;
if(minimum <= M){
extra += (M - minimum);
done[i] = 1;
arr[i] = 0;
}else{
arr[i] -= (M * A[i]);
}
}
for(ll i = 0;i < N;i++){
if(!done[i]){
ll minimum = arr[i] / B[i];
if(minimum * B[i] < arr[i]) minimum++;
if(minimum <= extra){
extra -= minimum;
done[i] = 1;
arr[i] = 0;
}else{
return false;
}
}
}
return true;
}
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
cin>>N>>M;
for(ll i = 0;i < N;i++){
cin>>A[i];
}
for(ll i = 0;i < N;i++){
cin>>B[i];
A[i] = max(A[i],B[i]);
}
ll high = 2e18 + 5;
ll low = 0;
while(high - low > 1){
ll mid = (high + low) / 2;
if(bs(mid)){
low = mid;
}else{
high = mid;
}
}
cout<<low<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 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 |
0 ms |
324 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 |
3 ms |
528 KB |
Output is correct |
11 |
Correct |
176 ms |
12760 KB |
Output is correct |
12 |
Correct |
177 ms |
12760 KB |
Output is correct |
13 |
Correct |
171 ms |
11508 KB |
Output is correct |
14 |
Correct |
166 ms |
11340 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
204 ms |
8788 KB |
Output is correct |
17 |
Correct |
193 ms |
13244 KB |
Output is correct |
18 |
Correct |
185 ms |
13020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
204 ms |
8788 KB |
Output is correct |
3 |
Correct |
193 ms |
13244 KB |
Output is correct |
4 |
Correct |
185 ms |
13020 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
94 ms |
6900 KB |
Output is correct |
14 |
Correct |
63 ms |
4684 KB |
Output is correct |
15 |
Correct |
46 ms |
3536 KB |
Output is correct |
16 |
Correct |
44 ms |
2952 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
324 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
324 KB |
Output is correct |
22 |
Correct |
4 ms |
408 KB |
Output is correct |
23 |
Correct |
4 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 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 |
0 ms |
324 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 |
3 ms |
528 KB |
Output is correct |
11 |
Correct |
176 ms |
12760 KB |
Output is correct |
12 |
Correct |
177 ms |
12760 KB |
Output is correct |
13 |
Correct |
171 ms |
11508 KB |
Output is correct |
14 |
Correct |
166 ms |
11340 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
324 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
94 ms |
6900 KB |
Output is correct |
24 |
Correct |
63 ms |
4684 KB |
Output is correct |
25 |
Correct |
46 ms |
3536 KB |
Output is correct |
26 |
Correct |
44 ms |
2952 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
324 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
324 KB |
Output is correct |
32 |
Correct |
4 ms |
408 KB |
Output is correct |
33 |
Correct |
4 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
204 ms |
8788 KB |
Output is correct |
36 |
Correct |
193 ms |
13244 KB |
Output is correct |
37 |
Correct |
185 ms |
13020 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
0 ms |
332 KB |
Output is correct |
40 |
Correct |
0 ms |
212 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
324 KB |
Output is correct |
44 |
Correct |
1 ms |
340 KB |
Output is correct |
45 |
Correct |
4 ms |
460 KB |
Output is correct |
46 |
Correct |
7 ms |
580 KB |
Output is correct |
47 |
Correct |
1 ms |
336 KB |
Output is correct |
48 |
Correct |
37 ms |
2568 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
4 ms |
468 KB |
Output is correct |
52 |
Correct |
1 ms |
212 KB |
Output is correct |
53 |
Correct |
0 ms |
212 KB |
Output is correct |
54 |
Correct |
1 ms |
212 KB |
Output is correct |
55 |
Correct |
98 ms |
6772 KB |
Output is correct |
56 |
Correct |
63 ms |
3972 KB |
Output is correct |
57 |
Correct |
57 ms |
4012 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 |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
94 ms |
6900 KB |
Output is correct |
10 |
Correct |
63 ms |
4684 KB |
Output is correct |
11 |
Correct |
46 ms |
3536 KB |
Output is correct |
12 |
Correct |
44 ms |
2952 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
324 KB |
Output is correct |
18 |
Correct |
4 ms |
408 KB |
Output is correct |
19 |
Correct |
4 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
204 ms |
8788 KB |
Output is correct |
22 |
Correct |
193 ms |
13244 KB |
Output is correct |
23 |
Correct |
185 ms |
13020 KB |
Output is correct |
24 |
Correct |
40 ms |
2340 KB |
Output is correct |
25 |
Correct |
111 ms |
6184 KB |
Output is correct |
26 |
Correct |
23 ms |
1684 KB |
Output is correct |
27 |
Correct |
187 ms |
13164 KB |
Output is correct |
28 |
Correct |
194 ms |
13112 KB |
Output is correct |
29 |
Correct |
201 ms |
13124 KB |
Output is correct |
30 |
Correct |
216 ms |
13144 KB |
Output is correct |
31 |
Correct |
270 ms |
13152 KB |
Output is correct |
32 |
Correct |
230 ms |
8808 KB |
Output is correct |
33 |
Correct |
249 ms |
13132 KB |
Output is correct |
34 |
Correct |
251 ms |
8900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 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 |
0 ms |
324 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 |
3 ms |
528 KB |
Output is correct |
11 |
Correct |
176 ms |
12760 KB |
Output is correct |
12 |
Correct |
177 ms |
12760 KB |
Output is correct |
13 |
Correct |
171 ms |
11508 KB |
Output is correct |
14 |
Correct |
166 ms |
11340 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
324 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
94 ms |
6900 KB |
Output is correct |
24 |
Correct |
63 ms |
4684 KB |
Output is correct |
25 |
Correct |
46 ms |
3536 KB |
Output is correct |
26 |
Correct |
44 ms |
2952 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
324 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
324 KB |
Output is correct |
32 |
Correct |
4 ms |
408 KB |
Output is correct |
33 |
Correct |
4 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
332 KB |
Output is correct |
36 |
Correct |
0 ms |
212 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
324 KB |
Output is correct |
40 |
Correct |
1 ms |
340 KB |
Output is correct |
41 |
Correct |
4 ms |
460 KB |
Output is correct |
42 |
Correct |
7 ms |
580 KB |
Output is correct |
43 |
Correct |
1 ms |
336 KB |
Output is correct |
44 |
Correct |
37 ms |
2568 KB |
Output is correct |
45 |
Correct |
0 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
212 KB |
Output is correct |
47 |
Correct |
4 ms |
468 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
98 ms |
6772 KB |
Output is correct |
52 |
Correct |
63 ms |
3972 KB |
Output is correct |
53 |
Correct |
57 ms |
4012 KB |
Output is correct |
54 |
Correct |
40 ms |
2340 KB |
Output is correct |
55 |
Correct |
111 ms |
6184 KB |
Output is correct |
56 |
Correct |
23 ms |
1684 KB |
Output is correct |
57 |
Correct |
187 ms |
13164 KB |
Output is correct |
58 |
Correct |
194 ms |
13112 KB |
Output is correct |
59 |
Correct |
201 ms |
13124 KB |
Output is correct |
60 |
Correct |
216 ms |
13144 KB |
Output is correct |
61 |
Correct |
270 ms |
13152 KB |
Output is correct |
62 |
Correct |
230 ms |
8808 KB |
Output is correct |
63 |
Correct |
249 ms |
13132 KB |
Output is correct |
64 |
Correct |
251 ms |
8900 KB |
Output is correct |
65 |
Correct |
1 ms |
212 KB |
Output is correct |
66 |
Correct |
204 ms |
8788 KB |
Output is correct |
67 |
Correct |
193 ms |
13244 KB |
Output is correct |
68 |
Correct |
185 ms |
13020 KB |
Output is correct |
69 |
Correct |
30 ms |
1632 KB |
Output is correct |
70 |
Correct |
7 ms |
592 KB |
Output is correct |
71 |
Correct |
1 ms |
212 KB |
Output is correct |
72 |
Correct |
42 ms |
2200 KB |
Output is correct |
73 |
Correct |
9 ms |
764 KB |
Output is correct |
74 |
Correct |
1 ms |
340 KB |
Output is correct |
75 |
Correct |
195 ms |
12756 KB |
Output is correct |
76 |
Correct |
206 ms |
12876 KB |
Output is correct |
77 |
Correct |
215 ms |
12760 KB |
Output is correct |
78 |
Correct |
241 ms |
12752 KB |
Output is correct |
79 |
Correct |
270 ms |
12692 KB |
Output is correct |
80 |
Correct |
273 ms |
12668 KB |
Output is correct |
81 |
Correct |
230 ms |
11340 KB |
Output is correct |
82 |
Correct |
227 ms |
11564 KB |
Output is correct |