#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=3e5+5;
ll n, m, a[nx], b[nx], l=1, r=1e15;
bool check(ll x)
{
ll vl=n*m;
for (int i=1; i<=n; i++)
{
if (vl*a[i]<x) return 0;
vl-=(x%a[i]==0)?(x/a[i]):(x/a[i]+1);
}
return 1;
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m;
for (int i=1; i<=n; i++) cin>>a[i];
for (int i=1; i<=n; i++) cin>>b[i];
while (l<r)
{
ll md=(l+r+1)/2;
if (check(md)) l=md;
else r=md-1;
}
cout<<l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 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 |
41 ms |
4696 KB |
Output is correct |
10 |
Correct |
27 ms |
4700 KB |
Output is correct |
11 |
Correct |
21 ms |
4700 KB |
Output is correct |
12 |
Correct |
17 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2648 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
23 ms |
4956 KB |
Output is correct |
22 |
Correct |
80 ms |
4956 KB |
Output is correct |
23 |
Correct |
79 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 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 |
41 ms |
4696 KB |
Output is correct |
10 |
Correct |
27 ms |
4700 KB |
Output is correct |
11 |
Correct |
21 ms |
4700 KB |
Output is correct |
12 |
Correct |
17 ms |
4700 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2648 KB |
Output is correct |
19 |
Correct |
2 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
23 ms |
4956 KB |
Output is correct |
22 |
Correct |
80 ms |
4956 KB |
Output is correct |
23 |
Correct |
79 ms |
4956 KB |
Output is correct |
24 |
Incorrect |
8 ms |
4696 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |