# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
703252 | MilosMilutinovic | Self Study (JOI22_ho_t2) | C++14 | 252 ms | 9104 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.
/**
* author: wxhtzdy
* created: 26.02.2023 19:18:55
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> b(n);
for (int i = 0; i < n; i++) {
cin >> b[i];
if (a[i] < b[i]) {
a[i] = b[i];
}
}
auto Solve = [&](long long x) {
long long f = 0;
for (int i = 0; i < n; i++) {
if (m * 1LL * a[i] >= x) {
long long take = (x + a[i] - 1) / a[i];
f += m - take;
}
}
for (int i = 0; i < n; i++) {
if (m * 1LL * a[i] < x) {
long long need = (x - m * 1LL * a[i] + b[i] - 1) / b[i];
f -= need;
if (f < 0) {
return false;
}
}
}
return f >= 0;
};
long long low = 0, high = 1e18, ans = 0;
while (low <= high) {
long long mid = low + high >> 1;
if (Solve(mid)) {
ans = mid;
low = mid + 1;
} else {
high = mid - 1;
}
}
cout << ans << '\n';
return 0;
}
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... |