이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
const ll inf = 3e18;
vector<ll> a(n), b(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
for (int i = 0; i < n; ++i) {
cin >> b[i];
}
ll L = 0, R = inf;
while (L + 1 < R) {
ll mid = (L + R) >> 1;
auto check = [&]() -> bool {
ll cnt = n * (ll)m;
for (int i = 0; i < n; ++i) {
if (b[i] >= a[i]) {
ll now = (mid + b[i] - 1) / b[i];
cnt -= now;
} else {
ll now = (mid + a[i] - 1) / a[i];
if (now <= m) {
cnt -= now;
} else {
ll whole = m + (mid - a[i] * m + b[i] - 1) / b[i];
cnt -= whole;
}
}
if (cnt < 0) {
return false;
}
}
return true;
};
if (check()) {
L = mid;
} else {
R = mid;
}
}
cout << L;
return 0;
}
# | 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... |