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>
#define int long long
using namespace std;
signed main() {
int n, k; cin >> n >> k; vector<int> a(n), b(n);
int l = 0, r = 0;
for(int i=0;i<n;i++) {cin >> a[i]; r = max(r,a[i]);}
for(int i=0;i<n;i++) {cin >> b[i]; r = max(r,b[i]);}
r *= k;
while(l<r) {
int m = l+(r-l+1)/2, c = 0;
for(int i=0;i<n;i++) {
if(m <= k*max(a[i],b[i])) c += (k-(m+max(a[i],b[i])-1)/max(a[i],b[i]));
else c -= (m-k*max(a[i],b[i])+b[i]-1)/b[i];
if(c <= -n*k) {r = m-1; break;}
}
if(c >= 0) l = m;
else r = m-1;
}
cout << l;
}
# | 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... |