| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1018827 | vjudge1 | Self Study (JOI22_ho_t2) | C++17 | 228 ms | 5120 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>
#define int long long
using namespace std;
signed main() {
int n, m;
cin >> n >> m;
vector <int> a(n), b(n);
int mx = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++) {
cin >> b[i];
}
auto check = [&](int p) {
int t = 0;
for (int i = 0; i < n; i++) {
if (b[i] > a[i]) {
int B = (p + b[i] -1) / b[i];
t += B;
} else {
if (a[i] * 1ll * m >= p) {
int A = (p + a[i] - 1) / a[i];
t += A;
} else {
int A = m;
int B = (p - a[i] * 1ll * A + b[i] -1) / b[i];
t += A + B;
}
}
if(t > n * 1ll * m) return false;
}
if(t <= n * 1ll * m) return true;
else return false;
};
int l = 0, r = 1e18 + 5;
while (r - l > 1) {
int mid = (l + r) >> 1;
if (check(mid)) {
l = mid;
} else {
r = mid;
}
}
if(check(r)) cout << r <<"\n";
else cout << l << "\n";
}
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... | ||||
