답안 #879934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879934 2023-11-28T11:13:27 Z frostray8653 Self Study (JOI22_ho_t2) C++17
100 / 100
388 ms 11384 KB
#include <bits/stdc++.h>
#define ll __int128_t
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
using pii = pair<int, int>;
const int N = 300005;
const int INF = 2e18;
int n, m;
int a[N], b[N];

bool check(ll k) {
    ll cst_day = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] >= b[i]) {
            ll need = (k + a[i] - 1) / a[i];
            if (need > m) {
                ll less = k - m * a[i];
                cst_day += (less + b[i] - 1) / b[i];
            } else {
                cst_day -= m - need;
            }
        } else {
            ll need = (k + b[i] - 1) / b[i];
            if (need > m)
                cst_day += need - m;
            else
                cst_day -= m - need;
        }
    }
    return (cst_day <= 0);
}

signed main() {
    IO;
    cin >> n >> m;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n) cin >> b[i];

    ll l = 0, r = 10000;
    while (check(r))
        r *= 2;
    while (l + 1 < r) {
        int mid = (l + r) >> 1;
        if (check(mid))
            l = mid;
        else
            r = mid;
    }
    int ans = l;
    cout << ans << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 1 ms 2480 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 134 ms 5056 KB Output is correct
12 Correct 116 ms 5132 KB Output is correct
13 Correct 95 ms 4952 KB Output is correct
14 Correct 154 ms 5132 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 66 ms 6308 KB Output is correct
17 Correct 148 ms 11344 KB Output is correct
18 Correct 70 ms 10836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 66 ms 6308 KB Output is correct
3 Correct 148 ms 11344 KB Output is correct
4 Correct 70 ms 10836 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 55 ms 4724 KB Output is correct
14 Correct 44 ms 4700 KB Output is correct
15 Correct 27 ms 4748 KB Output is correct
16 Correct 26 ms 4748 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 2 ms 2392 KB Output is correct
23 Correct 3 ms 2520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 1 ms 2480 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 134 ms 5056 KB Output is correct
12 Correct 116 ms 5132 KB Output is correct
13 Correct 95 ms 4952 KB Output is correct
14 Correct 154 ms 5132 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 55 ms 4724 KB Output is correct
24 Correct 44 ms 4700 KB Output is correct
25 Correct 27 ms 4748 KB Output is correct
26 Correct 26 ms 4748 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 2 ms 2392 KB Output is correct
33 Correct 3 ms 2520 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 66 ms 6308 KB Output is correct
36 Correct 148 ms 11344 KB Output is correct
37 Correct 70 ms 10836 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 0 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 4 ms 2652 KB Output is correct
46 Correct 6 ms 2648 KB Output is correct
47 Correct 1 ms 2656 KB Output is correct
48 Correct 31 ms 5972 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 4 ms 2396 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 0 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 87 ms 7488 KB Output is correct
56 Correct 36 ms 5976 KB Output is correct
57 Correct 53 ms 5980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 55 ms 4724 KB Output is correct
10 Correct 44 ms 4700 KB Output is correct
11 Correct 27 ms 4748 KB Output is correct
12 Correct 26 ms 4748 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 2 ms 2392 KB Output is correct
19 Correct 3 ms 2520 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 66 ms 6308 KB Output is correct
22 Correct 148 ms 11344 KB Output is correct
23 Correct 70 ms 10836 KB Output is correct
24 Correct 39 ms 5464 KB Output is correct
25 Correct 92 ms 7252 KB Output is correct
26 Correct 17 ms 5212 KB Output is correct
27 Correct 111 ms 10836 KB Output is correct
28 Correct 120 ms 10836 KB Output is correct
29 Correct 135 ms 10980 KB Output is correct
30 Correct 157 ms 10836 KB Output is correct
31 Correct 269 ms 10772 KB Output is correct
32 Correct 192 ms 6364 KB Output is correct
33 Correct 363 ms 11384 KB Output is correct
34 Correct 194 ms 6484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 1 ms 2480 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 134 ms 5056 KB Output is correct
12 Correct 116 ms 5132 KB Output is correct
13 Correct 95 ms 4952 KB Output is correct
14 Correct 154 ms 5132 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 55 ms 4724 KB Output is correct
24 Correct 44 ms 4700 KB Output is correct
25 Correct 27 ms 4748 KB Output is correct
26 Correct 26 ms 4748 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 2 ms 2392 KB Output is correct
33 Correct 3 ms 2520 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 0 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 2396 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 4 ms 2652 KB Output is correct
42 Correct 6 ms 2648 KB Output is correct
43 Correct 1 ms 2656 KB Output is correct
44 Correct 31 ms 5972 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 4 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 87 ms 7488 KB Output is correct
52 Correct 36 ms 5976 KB Output is correct
53 Correct 53 ms 5980 KB Output is correct
54 Correct 39 ms 5464 KB Output is correct
55 Correct 92 ms 7252 KB Output is correct
56 Correct 17 ms 5212 KB Output is correct
57 Correct 111 ms 10836 KB Output is correct
58 Correct 120 ms 10836 KB Output is correct
59 Correct 135 ms 10980 KB Output is correct
60 Correct 157 ms 10836 KB Output is correct
61 Correct 269 ms 10772 KB Output is correct
62 Correct 192 ms 6364 KB Output is correct
63 Correct 363 ms 11384 KB Output is correct
64 Correct 194 ms 6484 KB Output is correct
65 Correct 1 ms 2396 KB Output is correct
66 Correct 66 ms 6308 KB Output is correct
67 Correct 148 ms 11344 KB Output is correct
68 Correct 70 ms 10836 KB Output is correct
69 Correct 35 ms 5200 KB Output is correct
70 Correct 9 ms 2648 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 50 ms 5468 KB Output is correct
73 Correct 11 ms 2652 KB Output is correct
74 Correct 1 ms 2396 KB Output is correct
75 Correct 190 ms 10948 KB Output is correct
76 Correct 209 ms 10944 KB Output is correct
77 Correct 233 ms 10936 KB Output is correct
78 Correct 275 ms 10884 KB Output is correct
79 Correct 342 ms 10948 KB Output is correct
80 Correct 352 ms 11060 KB Output is correct
81 Correct 278 ms 8956 KB Output is correct
82 Correct 388 ms 8956 KB Output is correct