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;
#define int __int128
#define i64 int64_t
const int Z = 3e5, INF = 1e18;
i64 N, M, A[Z], B[Z];
int32_t main() {
ios::sync_with_stdio(0), cin.tie(0);
cin >> N >> M;
for(int i = 0; i < N; ++i) cin >> A[i];
for(int i = 0; i < N; ++i) cin >> B[i];
for(int i = 0; i < N; ++i)
A[i] = max(A[i], B[i]);
int ans = 0;
for(int add = 1LL<<62; add /= 2; ) {
int x = ans + add;
int free = 0;
for(int i = 0; i < N; ++i) {
int a_req = (x + A[i] - 1) / A[i];
if(a_req <= M)
free += M - a_req;
else {
int req = x - M * A[i];
int b_req = (req + B[i] - 1) / B[i];
free -= b_req;
}
}
if(free >= 0) ans += add;
}
cout << (int64_t)ans;
}
# | 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... |