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;
long long N, M;
long long A[300001], B[300001];
bool check(long long X) {
long long day = 0;
for (int i = 1; i <= N; i++) {
if (X <= A[i]*M) {
day += (X+A[i]-1)/A[i];
}
else {
day += M+(X-A[i]*M+B[i]-1)/B[i];
}
if (day > N*M) return false;
}
return true;
}
int main() {
cin >> N >> M;
for (int i = 1; i <= N; i++) {
cin >> A[i];
}
for (int i = 1; i <= N; i++) {
cin >> B[i];
A[i] = max(A[i], B[i]);
}
long long high = 1LL << 60;
long long low = 0;
while (high-low > 1) {
long long mid = (low+high)/2;
if (check(mid)) {
low = mid;
}
else {
high = mid;
}
}
cout << low << "\n";
}
# | 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... |