# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
706522 |
2023-03-06T21:16:22 Z |
xuliu |
Self Study (JOI22_ho_t2) |
C++17 |
|
299 ms |
10888 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug if(0)
const ll inf = 1e18+4;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, m; cin>>n>>m;
vector<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];
auto check = [&](ll x) {
// if can be done with minimum >= x
__int128 res = 0;
for(int i=0; i<n; i++) {
ll y = 0;
if(b[i] >= a[i]) y += (x+(b[i]-1))/b[i];
else {
ll t = (x+(a[i]-1))/a[i];
if(t > m) {
y += m;
ll t2 = ((x-m*a[i])+(b[i]-1))/b[i];
y += t2;
} else y += t;
}
res += y;
}
//debug cerr<<"x: "<<x<<", res = "<<res<<" ; n*m = "<<n*m<<"\n";
return res <= (n*m);
};
ll lo = 0, hi = inf;
while(lo < hi) {
ll m = (lo+hi+1)/2LL;
if(check(m)) lo = m;
else hi = m-1;
}
cout<<lo<<"\n";
}
# |
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 |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
4 ms |
460 KB |
Output is correct |
11 |
Correct |
208 ms |
10888 KB |
Output is correct |
12 |
Correct |
208 ms |
10816 KB |
Output is correct |
13 |
Correct |
153 ms |
8832 KB |
Output is correct |
14 |
Correct |
299 ms |
8908 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
195 ms |
5012 KB |
Output is correct |
17 |
Correct |
176 ms |
5008 KB |
Output is correct |
18 |
Correct |
174 ms |
5004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
195 ms |
5012 KB |
Output is correct |
3 |
Correct |
176 ms |
5008 KB |
Output is correct |
4 |
Correct |
174 ms |
5004 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 |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
82 ms |
2660 KB |
Output is correct |
14 |
Correct |
55 ms |
1876 KB |
Output is correct |
15 |
Correct |
40 ms |
1492 KB |
Output is correct |
16 |
Correct |
32 ms |
1260 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
4 ms |
340 KB |
Output is correct |
23 |
Correct |
4 ms |
396 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 |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
4 ms |
460 KB |
Output is correct |
11 |
Correct |
208 ms |
10888 KB |
Output is correct |
12 |
Correct |
208 ms |
10816 KB |
Output is correct |
13 |
Correct |
153 ms |
8832 KB |
Output is correct |
14 |
Correct |
299 ms |
8908 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 |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
82 ms |
2660 KB |
Output is correct |
24 |
Correct |
55 ms |
1876 KB |
Output is correct |
25 |
Correct |
40 ms |
1492 KB |
Output is correct |
26 |
Correct |
32 ms |
1260 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
4 ms |
340 KB |
Output is correct |
33 |
Correct |
4 ms |
396 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
195 ms |
5012 KB |
Output is correct |
36 |
Correct |
176 ms |
5008 KB |
Output is correct |
37 |
Correct |
174 ms |
5004 KB |
Output is correct |
38 |
Correct |
0 ms |
212 KB |
Output is correct |
39 |
Correct |
0 ms |
320 KB |
Output is correct |
40 |
Correct |
1 ms |
320 KB |
Output is correct |
41 |
Correct |
1 ms |
324 KB |
Output is correct |
42 |
Correct |
0 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
4 ms |
468 KB |
Output is correct |
46 |
Correct |
6 ms |
572 KB |
Output is correct |
47 |
Correct |
1 ms |
328 KB |
Output is correct |
48 |
Correct |
37 ms |
2020 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
4 ms |
460 KB |
Output is correct |
52 |
Correct |
1 ms |
212 KB |
Output is correct |
53 |
Correct |
1 ms |
212 KB |
Output is correct |
54 |
Correct |
1 ms |
324 KB |
Output is correct |
55 |
Correct |
104 ms |
5516 KB |
Output is correct |
56 |
Correct |
57 ms |
3172 KB |
Output is correct |
57 |
Correct |
111 ms |
3168 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 |
0 ms |
212 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 |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
82 ms |
2660 KB |
Output is correct |
10 |
Correct |
55 ms |
1876 KB |
Output is correct |
11 |
Correct |
40 ms |
1492 KB |
Output is correct |
12 |
Correct |
32 ms |
1260 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 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 |
4 ms |
340 KB |
Output is correct |
19 |
Correct |
4 ms |
396 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
195 ms |
5012 KB |
Output is correct |
22 |
Correct |
176 ms |
5008 KB |
Output is correct |
23 |
Correct |
174 ms |
5004 KB |
Output is correct |
24 |
Correct |
31 ms |
980 KB |
Output is correct |
25 |
Correct |
84 ms |
2428 KB |
Output is correct |
26 |
Correct |
19 ms |
724 KB |
Output is correct |
27 |
Correct |
159 ms |
5004 KB |
Output is correct |
28 |
Correct |
160 ms |
5016 KB |
Output is correct |
29 |
Correct |
159 ms |
5016 KB |
Output is correct |
30 |
Correct |
173 ms |
4948 KB |
Output is correct |
31 |
Correct |
231 ms |
5020 KB |
Output is correct |
32 |
Correct |
215 ms |
4948 KB |
Output is correct |
33 |
Correct |
245 ms |
5008 KB |
Output is correct |
34 |
Correct |
215 ms |
5008 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 |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
212 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 |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
320 KB |
Output is correct |
10 |
Correct |
4 ms |
460 KB |
Output is correct |
11 |
Correct |
208 ms |
10888 KB |
Output is correct |
12 |
Correct |
208 ms |
10816 KB |
Output is correct |
13 |
Correct |
153 ms |
8832 KB |
Output is correct |
14 |
Correct |
299 ms |
8908 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 |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
82 ms |
2660 KB |
Output is correct |
24 |
Correct |
55 ms |
1876 KB |
Output is correct |
25 |
Correct |
40 ms |
1492 KB |
Output is correct |
26 |
Correct |
32 ms |
1260 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
4 ms |
340 KB |
Output is correct |
33 |
Correct |
4 ms |
396 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
320 KB |
Output is correct |
36 |
Correct |
1 ms |
320 KB |
Output is correct |
37 |
Correct |
1 ms |
324 KB |
Output is correct |
38 |
Correct |
0 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
212 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
4 ms |
468 KB |
Output is correct |
42 |
Correct |
6 ms |
572 KB |
Output is correct |
43 |
Correct |
1 ms |
328 KB |
Output is correct |
44 |
Correct |
37 ms |
2020 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
212 KB |
Output is correct |
47 |
Correct |
4 ms |
460 KB |
Output is correct |
48 |
Correct |
1 ms |
212 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
324 KB |
Output is correct |
51 |
Correct |
104 ms |
5516 KB |
Output is correct |
52 |
Correct |
57 ms |
3172 KB |
Output is correct |
53 |
Correct |
111 ms |
3168 KB |
Output is correct |
54 |
Correct |
31 ms |
980 KB |
Output is correct |
55 |
Correct |
84 ms |
2428 KB |
Output is correct |
56 |
Correct |
19 ms |
724 KB |
Output is correct |
57 |
Correct |
159 ms |
5004 KB |
Output is correct |
58 |
Correct |
160 ms |
5016 KB |
Output is correct |
59 |
Correct |
159 ms |
5016 KB |
Output is correct |
60 |
Correct |
173 ms |
4948 KB |
Output is correct |
61 |
Correct |
231 ms |
5020 KB |
Output is correct |
62 |
Correct |
215 ms |
4948 KB |
Output is correct |
63 |
Correct |
245 ms |
5008 KB |
Output is correct |
64 |
Correct |
215 ms |
5008 KB |
Output is correct |
65 |
Correct |
0 ms |
212 KB |
Output is correct |
66 |
Correct |
195 ms |
5012 KB |
Output is correct |
67 |
Correct |
176 ms |
5008 KB |
Output is correct |
68 |
Correct |
174 ms |
5004 KB |
Output is correct |
69 |
Correct |
25 ms |
1452 KB |
Output is correct |
70 |
Correct |
7 ms |
596 KB |
Output is correct |
71 |
Correct |
1 ms |
212 KB |
Output is correct |
72 |
Correct |
35 ms |
1828 KB |
Output is correct |
73 |
Correct |
10 ms |
664 KB |
Output is correct |
74 |
Correct |
1 ms |
332 KB |
Output is correct |
75 |
Correct |
221 ms |
10828 KB |
Output is correct |
76 |
Correct |
205 ms |
10804 KB |
Output is correct |
77 |
Correct |
222 ms |
10748 KB |
Output is correct |
78 |
Correct |
227 ms |
10828 KB |
Output is correct |
79 |
Correct |
226 ms |
10804 KB |
Output is correct |
80 |
Correct |
227 ms |
10804 KB |
Output is correct |
81 |
Correct |
240 ms |
8708 KB |
Output is correct |
82 |
Correct |
216 ms |
8820 KB |
Output is correct |