# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062307 | ducksaysquack | Self Study (JOI22_ho_t2) | C++98 | 200 ms | 10836 KiB |
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);
for(int i=0;i<n;i++) cin >> a[i];
for(int i=0;i<n;i++) cin >> b[i];
int l=0, r=4e18;
while(l<r) {
int m = l+(r-l+1)/2, c = 0;
for(int i=0;i<n;i++) {
int x = (m+max(a[i],b[i])-1)/max(a[i],b[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 >= 0) l = m;
else r = m-1;
}
cout << l;
}
Compilation message (stderr)
# | 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... |