제출 #973850

#제출 시각아이디문제언어결과실행 시간메모리
973850blackslexSelf Study (JOI22_ho_t2)C++17
100 / 100
219 ms11776 KiB
#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;
                }
                if (cnt > n * m) return (bool) 0;
            }
            return cnt <= 1LL * n * m;
        };
        if (ck(mid)) l = mid + 1;
        else r = mid - 1;
    }
    printf("%lld", r);
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%lld %lld", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
Main.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for (auto &e: a) scanf("%lld", &e);
      |                      ~~~~~^~~~~~~~~~~~
Main.cpp:12:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for (auto &e: b) scanf("%lld", &e);
      |                      ~~~~~^~~~~~~~~~~~
#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...