제출 #1325071

#제출 시각아이디문제언어결과실행 시간메모리
1325071zwezdinvSelf Study (JOI22_ho_t2)C++20
0 / 100
135 ms5120 KiB
#include<bits/stdc++.h>

using ll = long long;

signed main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);

    int n, m;
    std::cin >> n >> m;
    std::vector<ll> a(n), b(n);
    for (auto& i : a) std::cin >> i;
    for (auto& i : b) std::cin >> i;
    auto check = [&](ll s) -> bool {
        ll bal = 0;
        for (int i = 0; i < n; ++i) {
            if (b[i] >= a[i]) {
                bal += (s + b[i] - 1) / b[i] - m;
            } else {
                ll k = (s + a[i] - 1) / a[i];
                if (k > m) {
                    bal += (s - a[i] * m + b[i] - 1) / b[i];
                } else {
                    bal -= m - k;
                }
            }
        }
        return bal <= 0;
    };
    ll L = 0, R = 1e18;
    while (L != R) {
        ll M = (L + R) / 2 + 1;
        if (check(M)) L = M;
        else R = M - 1;
    }
    std::cout << L;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...