답안 #862005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
862005 2023-10-17T11:09:45 Z keaucucal Self Study (JOI22_ho_t2) C++14
100 / 100
204 ms 9172 KB
#include <iostream>
#include <vector>
using namespace std;

using ll = long long;
const ll MAX_NUM = 1e9 * 1e9;

ll N, M;
vector<int> a;
vector<int> b;

inline bool ifEnoughCourses(const ll passline, ll courses) {
    for(int i = 0; i < N; i++) {
        if(b[i] >= a[i]) {
            courses -= (passline + b[i] - 1) / b[i];
        } else {
            if((passline + a[i] - 1) / a[i] <= M) {
                courses -= (passline + a[i] - 1) / a[i];
            } else {
                courses -= M + ((passline - M * a[i]) + b[i] - 1) / b[i];
            }
        }

        if(courses < 0) return false;
    }

    return true;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> N >> M;
    ll courses = N * M;
    a.resize(N);
    b.resize(N);
    for(int &i : a) cin >> i;
    for(int &i : b) cin >> i;

    ll l = 1, r = MAX_NUM;
    while(l < r) {
        ll mid = (l + r) / 2 + 1;

        if(ifEnoughCourses(mid, courses)) l = mid;
        else r = mid - 1;
    }

    cout << l << '\n';

    return 0;
}
# 결과 실행 시간 메모리 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 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 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 90 ms 8596 KB Output is correct
12 Correct 93 ms 8548 KB Output is correct
13 Correct 70 ms 6636 KB Output is correct
14 Correct 57 ms 6480 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 25 ms 3932 KB Output is correct
17 Correct 82 ms 9172 KB Output is correct
18 Correct 80 ms 8592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 25 ms 3932 KB Output is correct
3 Correct 82 ms 9172 KB Output is correct
4 Correct 80 ms 8592 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 0 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 47 ms 4436 KB Output is correct
14 Correct 28 ms 3164 KB Output is correct
15 Correct 20 ms 2392 KB Output is correct
16 Correct 18 ms 2064 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 348 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 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 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 90 ms 8596 KB Output is correct
12 Correct 93 ms 8548 KB Output is correct
13 Correct 70 ms 6636 KB Output is correct
14 Correct 57 ms 6480 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 0 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 47 ms 4436 KB Output is correct
24 Correct 28 ms 3164 KB Output is correct
25 Correct 20 ms 2392 KB Output is correct
26 Correct 18 ms 2064 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 25 ms 3932 KB Output is correct
36 Correct 82 ms 9172 KB Output is correct
37 Correct 80 ms 8592 KB Output is correct
38 Correct 0 ms 344 KB Output is correct
39 Correct 0 ms 456 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 456 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 2 ms 592 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 17 ms 1624 KB Output is correct
49 Correct 1 ms 600 KB Output is correct
50 Correct 0 ms 344 KB Output is correct
51 Correct 2 ms 348 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 60 ms 4428 KB Output is correct
56 Correct 26 ms 2396 KB Output is correct
57 Correct 23 ms 2392 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 0 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 47 ms 4436 KB Output is correct
10 Correct 28 ms 3164 KB Output is correct
11 Correct 20 ms 2392 KB Output is correct
12 Correct 18 ms 2064 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 25 ms 3932 KB Output is correct
22 Correct 82 ms 9172 KB Output is correct
23 Correct 80 ms 8592 KB Output is correct
24 Correct 27 ms 1964 KB Output is correct
25 Correct 61 ms 3944 KB Output is correct
26 Correct 10 ms 1116 KB Output is correct
27 Correct 78 ms 8552 KB Output is correct
28 Correct 85 ms 8552 KB Output is correct
29 Correct 86 ms 8420 KB Output is correct
30 Correct 110 ms 8424 KB Output is correct
31 Correct 180 ms 8528 KB Output is correct
32 Correct 104 ms 3932 KB Output is correct
33 Correct 204 ms 9044 KB Output is correct
34 Correct 104 ms 3964 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 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 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 90 ms 8596 KB Output is correct
12 Correct 93 ms 8548 KB Output is correct
13 Correct 70 ms 6636 KB Output is correct
14 Correct 57 ms 6480 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 0 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 47 ms 4436 KB Output is correct
24 Correct 28 ms 3164 KB Output is correct
25 Correct 20 ms 2392 KB Output is correct
26 Correct 18 ms 2064 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 0 ms 456 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 456 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 2 ms 592 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 17 ms 1624 KB Output is correct
45 Correct 1 ms 600 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 2 ms 348 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 60 ms 4428 KB Output is correct
52 Correct 26 ms 2396 KB Output is correct
53 Correct 23 ms 2392 KB Output is correct
54 Correct 27 ms 1964 KB Output is correct
55 Correct 61 ms 3944 KB Output is correct
56 Correct 10 ms 1116 KB Output is correct
57 Correct 78 ms 8552 KB Output is correct
58 Correct 85 ms 8552 KB Output is correct
59 Correct 86 ms 8420 KB Output is correct
60 Correct 110 ms 8424 KB Output is correct
61 Correct 180 ms 8528 KB Output is correct
62 Correct 104 ms 3932 KB Output is correct
63 Correct 204 ms 9044 KB Output is correct
64 Correct 104 ms 3964 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 25 ms 3932 KB Output is correct
67 Correct 82 ms 9172 KB Output is correct
68 Correct 80 ms 8592 KB Output is correct
69 Correct 20 ms 1332 KB Output is correct
70 Correct 5 ms 464 KB Output is correct
71 Correct 1 ms 344 KB Output is correct
72 Correct 30 ms 1628 KB Output is correct
73 Correct 6 ms 604 KB Output is correct
74 Correct 1 ms 480 KB Output is correct
75 Correct 104 ms 8820 KB Output is correct
76 Correct 106 ms 8372 KB Output is correct
77 Correct 133 ms 8552 KB Output is correct
78 Correct 146 ms 8600 KB Output is correct
79 Correct 203 ms 8728 KB Output is correct
80 Correct 201 ms 8528 KB Output is correct
81 Correct 193 ms 6368 KB Output is correct
82 Correct 192 ms 6612 KB Output is correct