#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,a[300005],b[300005];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n>>m;
for (int i=1; i<=n; ++i) cin>>a[i];
for (int i=1; i<=n; ++i) cin>>b[i], a[i]=max(a[i],b[i]);
ll l=0,r=1e18;
while (l<r) {
ll mid=(l+r+1)/2;
ll fre=0,want=0;
for (int i=1; i<=n; ++i) {
ll use=(mid+a[i]-1)/a[i];
if (use<=m) fre+=(m-use);
else want+=(mid-m*a[i]+b[i]-1)/b[i];
}
if (fre>=want) l=mid;
else r=mid-1;
}
cout<<l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
205 ms |
5000 KB |
Output is correct |
12 |
Correct |
205 ms |
4996 KB |
Output is correct |
13 |
Correct |
211 ms |
5000 KB |
Output is correct |
14 |
Incorrect |
428 ms |
4996 KB |
Output isn't correct |
15 |
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 |
0 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 |
106 ms |
2584 KB |
Output is correct |
10 |
Correct |
70 ms |
1876 KB |
Output is correct |
11 |
Correct |
52 ms |
1492 KB |
Output is correct |
12 |
Correct |
43 ms |
1264 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
316 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 |
Incorrect |
8 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
205 ms |
5000 KB |
Output is correct |
12 |
Correct |
205 ms |
4996 KB |
Output is correct |
13 |
Correct |
211 ms |
5000 KB |
Output is correct |
14 |
Incorrect |
428 ms |
4996 KB |
Output isn't correct |
15 |
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 |
0 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 |
106 ms |
2584 KB |
Output is correct |
10 |
Correct |
70 ms |
1876 KB |
Output is correct |
11 |
Correct |
52 ms |
1492 KB |
Output is correct |
12 |
Correct |
43 ms |
1264 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
316 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 |
Incorrect |
8 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
205 ms |
5000 KB |
Output is correct |
12 |
Correct |
205 ms |
4996 KB |
Output is correct |
13 |
Correct |
211 ms |
5000 KB |
Output is correct |
14 |
Incorrect |
428 ms |
4996 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |