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;
using ll = long long;
ll n, m;
ll l=0, r=3e18, mid;
ll a[300005], b[300005];
int main() {
cin.tie(0) -> sync_with_stdio(0);
cin >> n >> m;
for(int i=0;i<n;i++) cin >> a[i];
for(int i=0;i<n;i++) {
cin >> b[i];
a[i] = max(a[i], b[i]);
}
while(l <= r) {
mid = (l+r) >> 1;
ll treq=0, tfree=0;
for(int i=0;i<n;i++) {
ll times = (mid+a[i]-1)/a[i];
if(times > m) treq += (mid-m*a[i]+b[i]-1)/b[i];
else tfree += (m-times);
}
//cout << tfree << ' ' << treq << '\n';
if(tfree >= treq) l = mid + 1;
else r = mid - 1;
}
cout << r;
}
# | 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... |