답안 #921489

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921489 2024-02-04T02:43:07 Z cthbst Self Study (JOI22_ho_t2) C++14
62 / 100
326 ms 11052 KB
#include <algorithm>
#include <cmath>
#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]);
}

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 - ceil(1.0 * D / a[i]);
        } else {  // a[i] * m < D
            extra -= ceil(1.0 * (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 1 ms 2396 KB Output is correct
6 Correct 0 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 1 ms 2396 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 311 ms 5212 KB Output is correct
12 Correct 310 ms 4952 KB Output is correct
13 Correct 299 ms 5136 KB Output is correct
14 Correct 326 ms 5132 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 315 ms 5080 KB Output is correct
17 Correct 306 ms 4948 KB Output is correct
18 Correct 311 ms 5136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 315 ms 5080 KB Output is correct
3 Correct 306 ms 4948 KB Output is correct
4 Correct 311 ms 5136 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 2480 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 151 ms 4700 KB Output is correct
14 Correct 102 ms 4700 KB Output is correct
15 Correct 81 ms 4700 KB Output is correct
16 Correct 61 ms 4724 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 1 ms 2648 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 5 ms 2552 KB Output is correct
23 Correct 6 ms 2652 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 1 ms 2396 KB Output is correct
6 Correct 0 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 1 ms 2396 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 311 ms 5212 KB Output is correct
12 Correct 310 ms 4952 KB Output is correct
13 Correct 299 ms 5136 KB Output is correct
14 Correct 326 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 2480 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 151 ms 4700 KB Output is correct
24 Correct 102 ms 4700 KB Output is correct
25 Correct 81 ms 4700 KB Output is correct
26 Correct 61 ms 4724 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 1 ms 2648 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 5 ms 2552 KB Output is correct
33 Correct 6 ms 2652 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 315 ms 5080 KB Output is correct
36 Correct 306 ms 4948 KB Output is correct
37 Correct 311 ms 5136 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2392 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2512 KB Output is correct
45 Correct 6 ms 2652 KB Output is correct
46 Correct 10 ms 2652 KB Output is correct
47 Correct 1 ms 2524 KB Output is correct
48 Correct 53 ms 5724 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 6 ms 2396 KB Output is correct
52 Correct 1 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 155 ms 7596 KB Output is correct
56 Correct 99 ms 5980 KB Output is correct
57 Correct 107 ms 5988 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 2480 KB Output is correct
4 Correct 1 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 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 151 ms 4700 KB Output is correct
10 Correct 102 ms 4700 KB Output is correct
11 Correct 81 ms 4700 KB Output is correct
12 Correct 61 ms 4724 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 1 ms 2648 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 5 ms 2552 KB Output is correct
19 Correct 6 ms 2652 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 315 ms 5080 KB Output is correct
22 Correct 306 ms 4948 KB Output is correct
23 Correct 311 ms 5136 KB Output is correct
24 Correct 49 ms 5612 KB Output is correct
25 Correct 140 ms 7320 KB Output is correct
26 Correct 33 ms 5192 KB Output is correct
27 Correct 306 ms 11052 KB Output is correct
28 Correct 309 ms 10932 KB Output is correct
29 Correct 307 ms 10928 KB Output is correct
30 Correct 306 ms 10836 KB Output is correct
31 Incorrect 308 ms 10812 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 2396 KB Output is correct
6 Correct 0 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 1 ms 2396 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 311 ms 5212 KB Output is correct
12 Correct 310 ms 4952 KB Output is correct
13 Correct 299 ms 5136 KB Output is correct
14 Correct 326 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 2480 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 151 ms 4700 KB Output is correct
24 Correct 102 ms 4700 KB Output is correct
25 Correct 81 ms 4700 KB Output is correct
26 Correct 61 ms 4724 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 1 ms 2648 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 5 ms 2552 KB Output is correct
33 Correct 6 ms 2652 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2512 KB Output is correct
41 Correct 6 ms 2652 KB Output is correct
42 Correct 10 ms 2652 KB Output is correct
43 Correct 1 ms 2524 KB Output is correct
44 Correct 53 ms 5724 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 6 ms 2396 KB Output is correct
48 Correct 1 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 155 ms 7596 KB Output is correct
52 Correct 99 ms 5980 KB Output is correct
53 Correct 107 ms 5988 KB Output is correct
54 Correct 49 ms 5612 KB Output is correct
55 Correct 140 ms 7320 KB Output is correct
56 Correct 33 ms 5192 KB Output is correct
57 Correct 306 ms 11052 KB Output is correct
58 Correct 309 ms 10932 KB Output is correct
59 Correct 307 ms 10928 KB Output is correct
60 Correct 306 ms 10836 KB Output is correct
61 Incorrect 308 ms 10812 KB Output isn't correct
62 Halted 0 ms 0 KB -