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;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
ll n, m;
cin >> n >> m;
ll a[n], b[n];
for(int i=0; i<n; i++) cin >> a[i];
for(int i=0; i<n; i++) cin >> b[i];
ll lo = 0, hi = (ll)1<<60;
while(hi>lo) {
ll x = (lo+hi)/2;
ll ans = 0;
for(int i=0; i<n; i++) {
ll a1 = (x+b[i]-1)/b[i];
ll a2 = (x+a[i]-1)/a[i];
if(a2 > m) a2 = m + (x-a[i]*m+b[i]-1)/b[i];
ans += min(a1, a2);
}
if(ans <= n*m) lo = x+1;
else hi = x;
}
cout << lo-1;
}
# | 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... |