답안 #973850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973850 2024-05-02T11:51:57 Z blackslex Self Study (JOI22_ho_t2) C++17
100 / 100
219 ms 11776 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;
                }
                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);
}

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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 91 ms 4956 KB Output is correct
12 Correct 102 ms 5200 KB Output is correct
13 Correct 76 ms 4952 KB Output is correct
14 Correct 74 ms 4956 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 38 ms 6236 KB Output is correct
17 Correct 86 ms 11776 KB Output is correct
18 Correct 88 ms 10908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 38 ms 6236 KB Output is correct
3 Correct 86 ms 11776 KB Output is correct
4 Correct 88 ms 10908 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 45 ms 2900 KB Output is correct
14 Correct 31 ms 1988 KB Output is correct
15 Correct 25 ms 1624 KB Output is correct
16 Correct 20 ms 1372 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 500 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 91 ms 4956 KB Output is correct
12 Correct 102 ms 5200 KB Output is correct
13 Correct 76 ms 4952 KB Output is correct
14 Correct 74 ms 4956 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 45 ms 2900 KB Output is correct
24 Correct 31 ms 1988 KB Output is correct
25 Correct 25 ms 1624 KB Output is correct
26 Correct 20 ms 1372 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 500 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 38 ms 6236 KB Output is correct
36 Correct 86 ms 11776 KB Output is correct
37 Correct 88 ms 10908 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 436 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 432 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 2 ms 600 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 18 ms 2140 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 2 ms 596 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 53 ms 5800 KB Output is correct
56 Correct 32 ms 3160 KB Output is correct
57 Correct 24 ms 3288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 45 ms 2900 KB Output is correct
10 Correct 31 ms 1988 KB Output is correct
11 Correct 25 ms 1624 KB Output is correct
12 Correct 20 ms 1372 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 500 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 38 ms 6236 KB Output is correct
22 Correct 86 ms 11776 KB Output is correct
23 Correct 88 ms 10908 KB Output is correct
24 Correct 27 ms 1884 KB Output is correct
25 Correct 64 ms 4956 KB Output is correct
26 Correct 12 ms 1368 KB Output is correct
27 Correct 86 ms 10832 KB Output is correct
28 Correct 102 ms 10836 KB Output is correct
29 Correct 109 ms 10864 KB Output is correct
30 Correct 116 ms 10748 KB Output is correct
31 Correct 194 ms 10748 KB Output is correct
32 Correct 124 ms 6288 KB Output is correct
33 Correct 219 ms 11348 KB Output is correct
34 Correct 119 ms 6148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 344 KB Output is correct
11 Correct 91 ms 4956 KB Output is correct
12 Correct 102 ms 5200 KB Output is correct
13 Correct 76 ms 4952 KB Output is correct
14 Correct 74 ms 4956 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 45 ms 2900 KB Output is correct
24 Correct 31 ms 1988 KB Output is correct
25 Correct 25 ms 1624 KB Output is correct
26 Correct 20 ms 1372 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 500 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 436 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 432 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 2 ms 600 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 18 ms 2140 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 2 ms 596 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 53 ms 5800 KB Output is correct
52 Correct 32 ms 3160 KB Output is correct
53 Correct 24 ms 3288 KB Output is correct
54 Correct 27 ms 1884 KB Output is correct
55 Correct 64 ms 4956 KB Output is correct
56 Correct 12 ms 1368 KB Output is correct
57 Correct 86 ms 10832 KB Output is correct
58 Correct 102 ms 10836 KB Output is correct
59 Correct 109 ms 10864 KB Output is correct
60 Correct 116 ms 10748 KB Output is correct
61 Correct 194 ms 10748 KB Output is correct
62 Correct 124 ms 6288 KB Output is correct
63 Correct 219 ms 11348 KB Output is correct
64 Correct 119 ms 6148 KB Output is correct
65 Correct 1 ms 344 KB Output is correct
66 Correct 38 ms 6236 KB Output is correct
67 Correct 86 ms 11776 KB Output is correct
68 Correct 88 ms 10908 KB Output is correct
69 Correct 21 ms 1576 KB Output is correct
70 Correct 6 ms 604 KB Output is correct
71 Correct 0 ms 344 KB Output is correct
72 Correct 30 ms 1880 KB Output is correct
73 Correct 6 ms 604 KB Output is correct
74 Correct 1 ms 604 KB Output is correct
75 Correct 105 ms 10876 KB Output is correct
76 Correct 114 ms 11112 KB Output is correct
77 Correct 122 ms 10736 KB Output is correct
78 Correct 155 ms 10832 KB Output is correct
79 Correct 206 ms 10876 KB Output is correct
80 Correct 214 ms 10912 KB Output is correct
81 Correct 206 ms 8788 KB Output is correct
82 Correct 205 ms 8932 KB Output is correct