답안 #811001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
811001 2023-08-06T19:27:22 Z tkwiatkowski Self Study (JOI22_ho_t2) C++17
100 / 100
322 ms 9168 KB
#include <iostream>
#include <vector>
using namespace std;

bool check(long long min_lvl, int m, vector<int> &A, vector<int> &B) {
    long long cnt = 0;
    int n = A.size();
    for (int i = 0; i < n; ++i) {
        int a = max(A[i], B[i]);
        int b = B[i];
        long long curr_cnt = min((long long)m, (min_lvl + a - 1) / a);
        cnt += curr_cnt + max((long long)0, (min_lvl - curr_cnt * a + b - 1) / b);
        if (cnt > (long long)n * m)
            return false;
    }
    return true;
}

long long BS(int m, vector<int> &A, vector<int> &B) {
    long long lo = 0, hi = 1e18;
    while (lo < hi) {
        long long mid = (lo + hi + 1) / 2;
        if (check(mid, m, A, B))
            lo = mid;
        else
            hi = mid - 1;
    }
    return lo;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<int> A(n), B(n);
    for (auto &a : A)
        cin >> a;
    for (auto &b : B)
        cin >> b;

    cout << BS(m, A, B) << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 118 ms 4296 KB Output is correct
12 Correct 126 ms 4324 KB Output is correct
13 Correct 99 ms 4248 KB Output is correct
14 Correct 85 ms 4300 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 29 ms 3820 KB Output is correct
17 Correct 111 ms 9168 KB Output is correct
18 Correct 116 ms 8468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 29 ms 3820 KB Output is correct
3 Correct 111 ms 9168 KB Output is correct
4 Correct 116 ms 8468 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 316 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 61 ms 3156 KB Output is correct
14 Correct 41 ms 2636 KB Output is correct
15 Correct 30 ms 2312 KB Output is correct
16 Correct 25 ms 1876 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 118 ms 4296 KB Output is correct
12 Correct 126 ms 4324 KB Output is correct
13 Correct 99 ms 4248 KB Output is correct
14 Correct 85 ms 4300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 316 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 320 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 61 ms 3156 KB Output is correct
24 Correct 41 ms 2636 KB Output is correct
25 Correct 30 ms 2312 KB Output is correct
26 Correct 25 ms 1876 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 29 ms 3820 KB Output is correct
36 Correct 111 ms 9168 KB Output is correct
37 Correct 116 ms 8468 KB Output is correct
38 Correct 0 ms 320 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 316 KB Output is correct
45 Correct 3 ms 340 KB Output is correct
46 Correct 4 ms 468 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 22 ms 1720 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 3 ms 452 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 0 ms 212 KB Output is correct
55 Correct 62 ms 4296 KB Output is correct
56 Correct 39 ms 2376 KB Output is correct
57 Correct 32 ms 2384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 61 ms 3156 KB Output is correct
10 Correct 41 ms 2636 KB Output is correct
11 Correct 30 ms 2312 KB Output is correct
12 Correct 25 ms 1876 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 29 ms 3820 KB Output is correct
22 Correct 111 ms 9168 KB Output is correct
23 Correct 116 ms 8468 KB Output is correct
24 Correct 37 ms 1492 KB Output is correct
25 Correct 89 ms 3916 KB Output is correct
26 Correct 16 ms 1236 KB Output is correct
27 Correct 116 ms 8456 KB Output is correct
28 Correct 124 ms 8412 KB Output is correct
29 Correct 129 ms 8416 KB Output is correct
30 Correct 160 ms 8452 KB Output is correct
31 Correct 254 ms 8456 KB Output is correct
32 Correct 156 ms 3796 KB Output is correct
33 Correct 285 ms 9112 KB Output is correct
34 Correct 162 ms 3828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 118 ms 4296 KB Output is correct
12 Correct 126 ms 4324 KB Output is correct
13 Correct 99 ms 4248 KB Output is correct
14 Correct 85 ms 4300 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 316 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 320 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 61 ms 3156 KB Output is correct
24 Correct 41 ms 2636 KB Output is correct
25 Correct 30 ms 2312 KB Output is correct
26 Correct 25 ms 1876 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 3 ms 340 KB Output is correct
34 Correct 0 ms 320 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 316 KB Output is correct
41 Correct 3 ms 340 KB Output is correct
42 Correct 4 ms 468 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 22 ms 1720 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 3 ms 452 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 62 ms 4296 KB Output is correct
52 Correct 39 ms 2376 KB Output is correct
53 Correct 32 ms 2384 KB Output is correct
54 Correct 37 ms 1492 KB Output is correct
55 Correct 89 ms 3916 KB Output is correct
56 Correct 16 ms 1236 KB Output is correct
57 Correct 116 ms 8456 KB Output is correct
58 Correct 124 ms 8412 KB Output is correct
59 Correct 129 ms 8416 KB Output is correct
60 Correct 160 ms 8452 KB Output is correct
61 Correct 254 ms 8456 KB Output is correct
62 Correct 156 ms 3796 KB Output is correct
63 Correct 285 ms 9112 KB Output is correct
64 Correct 162 ms 3828 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 29 ms 3820 KB Output is correct
67 Correct 111 ms 9168 KB Output is correct
68 Correct 116 ms 8468 KB Output is correct
69 Correct 27 ms 1108 KB Output is correct
70 Correct 7 ms 460 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 41 ms 1484 KB Output is correct
73 Correct 8 ms 468 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 128 ms 8476 KB Output is correct
76 Correct 142 ms 8460 KB Output is correct
77 Correct 157 ms 8420 KB Output is correct
78 Correct 200 ms 8416 KB Output is correct
79 Correct 268 ms 8456 KB Output is correct
80 Correct 275 ms 8460 KB Output is correct
81 Correct 274 ms 6480 KB Output is correct
82 Correct 322 ms 6476 KB Output is correct