This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,m;
cin >> n >> m;
int64_t a[n],b[n];
for(int i = 0;i < n;++i)
{
cin >> a[i];
}
for(int i = 0;i < n;++i)
{
cin >> b[i];
if(a[i] < b[i])
a[i] = b[i];
}
int64_t l = 0,r = 1e18;
while(l < r)
{
int64_t mid = (l+r+1)/2;
__int128 sv = 0;
__int128 bv = 0;
for(int j = 0;j < n;++j)
{
sv += max(int64_t(0),m-((mid+a[j]-1)/a[j]));
bv += max(int64_t(0),(mid-m*a[j]+b[j]-1)/b[j]);
}
sv < bv ? r = mid-1 : l = mid;
}
cout << l;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |