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