답안 #921492

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921492 2024-02-04T02:47:17 Z cthbst Self Study (JOI22_ho_t2) C++14
100 / 100
204 ms 5208 KB
#include <algorithm>
#include <iostream>

#define int long long

using namespace std;

const int MAXN = 300005;

int n, m;
int a[MAXN];
int b[MAXN];

void init() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    for (int i = 0; i < n; i++) a[i] = max(a[i], b[i]);
}

int div_ceil(int x, int y) {
    int ans = x / y;
    if (x % y > 0) ans++;
    return ans;
}

bool check(int D) {
    __int128 extra = 0;
    // cout << "D = " << D << '\n';
    for (int i = 0; i < n; i++) {
        if (a[i] * m >= D) {
            extra += m - div_ceil(D, a[i]);
        } else {  // a[i] * m < D
            extra -= div_ceil(D - a[i] * m, b[i]);
        }
    }
    return extra >= 0;
}

void solve() {
    int l = 1;
    int r = 1 + (int)1e18;

    // check(D) : D 愈小愈容易
    while (l != r) {
        int mid = (l + r) / 2;
        if (check(mid) == false) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    int ans = r - 1;
    cout << ans << '\n';
}

signed main() {
    cin.tie(0);
    cin.sync_with_stdio(0);

    init();
    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 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 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 142 ms 4956 KB Output is correct
12 Correct 148 ms 5128 KB Output is correct
13 Correct 131 ms 4956 KB Output is correct
14 Correct 180 ms 5128 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 177 ms 5208 KB Output is correct
17 Correct 142 ms 4944 KB Output is correct
18 Correct 142 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 177 ms 5208 KB Output is correct
3 Correct 142 ms 4944 KB Output is correct
4 Correct 142 ms 4956 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 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 81 ms 4700 KB Output is correct
14 Correct 48 ms 4696 KB Output is correct
15 Correct 36 ms 4700 KB Output is correct
16 Correct 30 ms 4744 KB Output is correct
17 Correct 1 ms 2408 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2480 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 5 ms 2396 KB Output is correct
23 Correct 3 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 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 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 142 ms 4956 KB Output is correct
12 Correct 148 ms 5128 KB Output is correct
13 Correct 131 ms 4956 KB Output is correct
14 Correct 180 ms 5128 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 2392 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 81 ms 4700 KB Output is correct
24 Correct 48 ms 4696 KB Output is correct
25 Correct 36 ms 4700 KB Output is correct
26 Correct 30 ms 4744 KB Output is correct
27 Correct 1 ms 2408 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2480 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 5 ms 2396 KB Output is correct
33 Correct 3 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 177 ms 5208 KB Output is correct
36 Correct 142 ms 4944 KB Output is correct
37 Correct 142 ms 4956 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 0 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 3 ms 2396 KB Output is correct
46 Correct 5 ms 2536 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 28 ms 4724 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 3 ms 2396 KB Output is correct
52 Correct 0 ms 2396 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 71 ms 4568 KB Output is correct
56 Correct 45 ms 4728 KB Output is correct
57 Correct 60 ms 4700 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 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 81 ms 4700 KB Output is correct
10 Correct 48 ms 4696 KB Output is correct
11 Correct 36 ms 4700 KB Output is correct
12 Correct 30 ms 4744 KB Output is correct
13 Correct 1 ms 2408 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2480 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 5 ms 2396 KB Output is correct
19 Correct 3 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 177 ms 5208 KB Output is correct
22 Correct 142 ms 4944 KB Output is correct
23 Correct 142 ms 4956 KB Output is correct
24 Correct 29 ms 4700 KB Output is correct
25 Correct 76 ms 4696 KB Output is correct
26 Correct 17 ms 4700 KB Output is correct
27 Correct 157 ms 5132 KB Output is correct
28 Correct 141 ms 5128 KB Output is correct
29 Correct 142 ms 4948 KB Output is correct
30 Correct 155 ms 4956 KB Output is correct
31 Correct 200 ms 5072 KB Output is correct
32 Correct 188 ms 5132 KB Output is correct
33 Correct 204 ms 4956 KB Output is correct
34 Correct 182 ms 5132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 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 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 142 ms 4956 KB Output is correct
12 Correct 148 ms 5128 KB Output is correct
13 Correct 131 ms 4956 KB Output is correct
14 Correct 180 ms 5128 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 2392 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 81 ms 4700 KB Output is correct
24 Correct 48 ms 4696 KB Output is correct
25 Correct 36 ms 4700 KB Output is correct
26 Correct 30 ms 4744 KB Output is correct
27 Correct 1 ms 2408 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2480 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 5 ms 2396 KB Output is correct
33 Correct 3 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 0 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 0 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 3 ms 2396 KB Output is correct
42 Correct 5 ms 2536 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 28 ms 4724 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 3 ms 2396 KB Output is correct
48 Correct 0 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 71 ms 4568 KB Output is correct
52 Correct 45 ms 4728 KB Output is correct
53 Correct 60 ms 4700 KB Output is correct
54 Correct 29 ms 4700 KB Output is correct
55 Correct 76 ms 4696 KB Output is correct
56 Correct 17 ms 4700 KB Output is correct
57 Correct 157 ms 5132 KB Output is correct
58 Correct 141 ms 5128 KB Output is correct
59 Correct 142 ms 4948 KB Output is correct
60 Correct 155 ms 4956 KB Output is correct
61 Correct 200 ms 5072 KB Output is correct
62 Correct 188 ms 5132 KB Output is correct
63 Correct 204 ms 4956 KB Output is correct
64 Correct 182 ms 5132 KB Output is correct
65 Correct 1 ms 2396 KB Output is correct
66 Correct 177 ms 5208 KB Output is correct
67 Correct 142 ms 4944 KB Output is correct
68 Correct 142 ms 4956 KB Output is correct
69 Correct 21 ms 4820 KB Output is correct
70 Correct 6 ms 2576 KB Output is correct
71 Correct 1 ms 2392 KB Output is correct
72 Correct 29 ms 4896 KB Output is correct
73 Correct 8 ms 2392 KB Output is correct
74 Correct 1 ms 2392 KB Output is correct
75 Correct 143 ms 5072 KB Output is correct
76 Correct 149 ms 5132 KB Output is correct
77 Correct 150 ms 5128 KB Output is correct
78 Correct 166 ms 5132 KB Output is correct
79 Correct 193 ms 4948 KB Output is correct
80 Correct 196 ms 5132 KB Output is correct
81 Correct 194 ms 4956 KB Output is correct
82 Correct 192 ms 4944 KB Output is correct