# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973848 | blackslex | Self Study (JOI22_ho_t2) | C++17 | 437 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>
using namespace std;
using ll = long long;
ll n, m;
int main() {
scanf("%lld %lld", &n, &m);
vector<ll> a(n), b(n);
for (auto &e: a) scanf("%lld", &e);
for (auto &e: b) scanf("%lld", &e);
ll l = 1, r = 1e18;
while (l <= r) {
ll mid = (l + r) >> 1LL;
auto ck = [&] (ll val) {
ll cnt = 0;
for (int i = 0; i < n; i++) {
if (b[i] >= a[i]) cnt += (val - 1) / b[i] + 1;
else {
ll cur = (val - 1) / a[i] + 1; cur = min(cur, m); cnt += cur;
ll cval = val - cur * a[i];
if (cval > 0) cnt += (cval - 1) / b[i] + 1;
}
}
return cnt <= 1LL * n * m;
};
if (ck(mid)) l = mid + 1;
else r = mid - 1;
}
printf("%lld", r);
}
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... |