#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 3e5;
const ll inf = 1e9;
const ll infll = 1e18;
ll v[N],v2[N];
int main(){
ll n,m;
cin>>n>>m;
for(ll i = 0;i < n;i++){
cin>>v[i];
}
for(ll i = 0;i < n;i++){
cin>>v2[i];
v[i] = max(v[i],v2[i]);
}
ll l = 0,r = m*inf;
while(l != r){
ll mij = (l + r + 1)/2;
__int128 nr = 0;
for(ll i = 0;i < n;i++){
ll req2 = (mij + v[i] - 1)/v[i];
if(req2 <= m)nr+=m - req2;
else{
nr-=(mij - m*v[i] + v2[i] - 1)/v2[i];
}
}
//cout<<mij<<' '<<bonus<<' '<<req<<'\n';
if(nr >= 0){
l = mij;
}else r = mij - 1;
}
cout<<l<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
3 ms |
2396 KB |
Output is correct |
11 |
Correct |
148 ms |
4864 KB |
Output is correct |
12 |
Correct |
149 ms |
4944 KB |
Output is correct |
13 |
Correct |
118 ms |
4940 KB |
Output is correct |
14 |
Correct |
116 ms |
4948 KB |
Output is correct |
15 |
Correct |
1 ms |
2652 KB |
Output is correct |
16 |
Correct |
95 ms |
6096 KB |
Output is correct |
17 |
Correct |
169 ms |
11344 KB |
Output is correct |
18 |
Correct |
153 ms |
10832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
95 ms |
6096 KB |
Output is correct |
3 |
Correct |
169 ms |
11344 KB |
Output is correct |
4 |
Correct |
153 ms |
10832 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
82 ms |
4636 KB |
Output is correct |
14 |
Correct |
55 ms |
4540 KB |
Output is correct |
15 |
Correct |
42 ms |
4688 KB |
Output is correct |
16 |
Correct |
45 ms |
4700 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2460 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
2 ms |
2524 KB |
Output is correct |
23 |
Correct |
3 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
3 ms |
2396 KB |
Output is correct |
11 |
Correct |
148 ms |
4864 KB |
Output is correct |
12 |
Correct |
149 ms |
4944 KB |
Output is correct |
13 |
Correct |
118 ms |
4940 KB |
Output is correct |
14 |
Correct |
116 ms |
4948 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
0 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
2396 KB |
Output is correct |
23 |
Correct |
82 ms |
4636 KB |
Output is correct |
24 |
Correct |
55 ms |
4540 KB |
Output is correct |
25 |
Correct |
42 ms |
4688 KB |
Output is correct |
26 |
Correct |
45 ms |
4700 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2460 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
0 ms |
2396 KB |
Output is correct |
32 |
Correct |
2 ms |
2524 KB |
Output is correct |
33 |
Correct |
3 ms |
2396 KB |
Output is correct |
34 |
Correct |
1 ms |
2652 KB |
Output is correct |
35 |
Correct |
95 ms |
6096 KB |
Output is correct |
36 |
Correct |
169 ms |
11344 KB |
Output is correct |
37 |
Correct |
153 ms |
10832 KB |
Output is correct |
38 |
Correct |
1 ms |
2392 KB |
Output is correct |
39 |
Correct |
0 ms |
2392 KB |
Output is correct |
40 |
Correct |
1 ms |
2396 KB |
Output is correct |
41 |
Correct |
1 ms |
2408 KB |
Output is correct |
42 |
Correct |
0 ms |
2396 KB |
Output is correct |
43 |
Correct |
0 ms |
2396 KB |
Output is correct |
44 |
Correct |
1 ms |
2396 KB |
Output is correct |
45 |
Correct |
3 ms |
2396 KB |
Output is correct |
46 |
Correct |
5 ms |
2604 KB |
Output is correct |
47 |
Correct |
1 ms |
2396 KB |
Output is correct |
48 |
Correct |
29 ms |
5468 KB |
Output is correct |
49 |
Correct |
1 ms |
2396 KB |
Output is correct |
50 |
Correct |
1 ms |
2396 KB |
Output is correct |
51 |
Correct |
3 ms |
2396 KB |
Output is correct |
52 |
Correct |
1 ms |
2396 KB |
Output is correct |
53 |
Correct |
0 ms |
2396 KB |
Output is correct |
54 |
Correct |
0 ms |
2396 KB |
Output is correct |
55 |
Correct |
82 ms |
6512 KB |
Output is correct |
56 |
Correct |
40 ms |
4436 KB |
Output is correct |
57 |
Correct |
47 ms |
5968 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
82 ms |
4636 KB |
Output is correct |
10 |
Correct |
55 ms |
4540 KB |
Output is correct |
11 |
Correct |
42 ms |
4688 KB |
Output is correct |
12 |
Correct |
45 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2460 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
2396 KB |
Output is correct |
18 |
Correct |
2 ms |
2524 KB |
Output is correct |
19 |
Correct |
3 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2652 KB |
Output is correct |
21 |
Correct |
95 ms |
6096 KB |
Output is correct |
22 |
Correct |
169 ms |
11344 KB |
Output is correct |
23 |
Correct |
153 ms |
10832 KB |
Output is correct |
24 |
Correct |
28 ms |
3676 KB |
Output is correct |
25 |
Correct |
85 ms |
5924 KB |
Output is correct |
26 |
Correct |
17 ms |
5312 KB |
Output is correct |
27 |
Correct |
149 ms |
10832 KB |
Output is correct |
28 |
Correct |
169 ms |
10776 KB |
Output is correct |
29 |
Correct |
164 ms |
10836 KB |
Output is correct |
30 |
Correct |
178 ms |
10892 KB |
Output is correct |
31 |
Correct |
183 ms |
10912 KB |
Output is correct |
32 |
Correct |
125 ms |
6228 KB |
Output is correct |
33 |
Correct |
186 ms |
11344 KB |
Output is correct |
34 |
Correct |
122 ms |
6260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
3 ms |
2396 KB |
Output is correct |
11 |
Correct |
148 ms |
4864 KB |
Output is correct |
12 |
Correct |
149 ms |
4944 KB |
Output is correct |
13 |
Correct |
118 ms |
4940 KB |
Output is correct |
14 |
Correct |
116 ms |
4948 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
0 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
2396 KB |
Output is correct |
23 |
Correct |
82 ms |
4636 KB |
Output is correct |
24 |
Correct |
55 ms |
4540 KB |
Output is correct |
25 |
Correct |
42 ms |
4688 KB |
Output is correct |
26 |
Correct |
45 ms |
4700 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2460 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
0 ms |
2396 KB |
Output is correct |
32 |
Correct |
2 ms |
2524 KB |
Output is correct |
33 |
Correct |
3 ms |
2396 KB |
Output is correct |
34 |
Correct |
1 ms |
2392 KB |
Output is correct |
35 |
Correct |
0 ms |
2392 KB |
Output is correct |
36 |
Correct |
1 ms |
2396 KB |
Output is correct |
37 |
Correct |
1 ms |
2408 KB |
Output is correct |
38 |
Correct |
0 ms |
2396 KB |
Output is correct |
39 |
Correct |
0 ms |
2396 KB |
Output is correct |
40 |
Correct |
1 ms |
2396 KB |
Output is correct |
41 |
Correct |
3 ms |
2396 KB |
Output is correct |
42 |
Correct |
5 ms |
2604 KB |
Output is correct |
43 |
Correct |
1 ms |
2396 KB |
Output is correct |
44 |
Correct |
29 ms |
5468 KB |
Output is correct |
45 |
Correct |
1 ms |
2396 KB |
Output is correct |
46 |
Correct |
1 ms |
2396 KB |
Output is correct |
47 |
Correct |
3 ms |
2396 KB |
Output is correct |
48 |
Correct |
1 ms |
2396 KB |
Output is correct |
49 |
Correct |
0 ms |
2396 KB |
Output is correct |
50 |
Correct |
0 ms |
2396 KB |
Output is correct |
51 |
Correct |
82 ms |
6512 KB |
Output is correct |
52 |
Correct |
40 ms |
4436 KB |
Output is correct |
53 |
Correct |
47 ms |
5968 KB |
Output is correct |
54 |
Correct |
28 ms |
3676 KB |
Output is correct |
55 |
Correct |
85 ms |
5924 KB |
Output is correct |
56 |
Correct |
17 ms |
5312 KB |
Output is correct |
57 |
Correct |
149 ms |
10832 KB |
Output is correct |
58 |
Correct |
169 ms |
10776 KB |
Output is correct |
59 |
Correct |
164 ms |
10836 KB |
Output is correct |
60 |
Correct |
178 ms |
10892 KB |
Output is correct |
61 |
Correct |
183 ms |
10912 KB |
Output is correct |
62 |
Correct |
125 ms |
6228 KB |
Output is correct |
63 |
Correct |
186 ms |
11344 KB |
Output is correct |
64 |
Correct |
122 ms |
6260 KB |
Output is correct |
65 |
Correct |
1 ms |
2652 KB |
Output is correct |
66 |
Correct |
95 ms |
6096 KB |
Output is correct |
67 |
Correct |
169 ms |
11344 KB |
Output is correct |
68 |
Correct |
153 ms |
10832 KB |
Output is correct |
69 |
Correct |
21 ms |
5212 KB |
Output is correct |
70 |
Correct |
10 ms |
2668 KB |
Output is correct |
71 |
Correct |
1 ms |
2496 KB |
Output is correct |
72 |
Correct |
28 ms |
3520 KB |
Output is correct |
73 |
Correct |
7 ms |
2648 KB |
Output is correct |
74 |
Correct |
1 ms |
2396 KB |
Output is correct |
75 |
Correct |
165 ms |
11172 KB |
Output is correct |
76 |
Correct |
183 ms |
10908 KB |
Output is correct |
77 |
Correct |
171 ms |
10832 KB |
Output is correct |
78 |
Correct |
183 ms |
10832 KB |
Output is correct |
79 |
Correct |
183 ms |
10832 KB |
Output is correct |
80 |
Correct |
187 ms |
10836 KB |
Output is correct |
81 |
Correct |
128 ms |
8784 KB |
Output is correct |
82 |
Correct |
137 ms |
8872 KB |
Output is correct |