답안 #973848

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973848 2024-05-02T11:49:56 Z blackslex Self Study (JOI22_ho_t2) C++17
0 / 100
437 ms 10836 KB
#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

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);
      |                      ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 440 KB Output is correct
11 Correct 198 ms 10836 KB Output is correct
12 Correct 181 ms 10836 KB Output is correct
13 Correct 143 ms 8788 KB Output is correct
14 Incorrect 437 ms 9088 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 76 ms 5668 KB Output is correct
10 Correct 51 ms 3928 KB Output is correct
11 Correct 38 ms 3048 KB Output is correct
12 Correct 30 ms 2392 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 600 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 5 ms 520 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 440 KB Output is correct
11 Correct 198 ms 10836 KB Output is correct
12 Correct 181 ms 10836 KB Output is correct
13 Correct 143 ms 8788 KB Output is correct
14 Incorrect 437 ms 9088 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 76 ms 5668 KB Output is correct
10 Correct 51 ms 3928 KB Output is correct
11 Correct 38 ms 3048 KB Output is correct
12 Correct 30 ms 2392 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 600 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 5 ms 520 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 440 KB Output is correct
11 Correct 198 ms 10836 KB Output is correct
12 Correct 181 ms 10836 KB Output is correct
13 Correct 143 ms 8788 KB Output is correct
14 Incorrect 437 ms 9088 KB Output isn't correct
15 Halted 0 ms 0 KB -