답안 #941212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941212 2024-03-08T09:39:38 Z peterandvoi Self Study (JOI22_ho_t2) C++17
100 / 100
220 ms 9172 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef ngu
#include "debug.h"
#else
#define debug(...) 42
#endif

const int N = (int) 3e5 + 5;

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

bool check(long long mid) {
    long long cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[i] < b[i]) {
            cnt += (mid - 1) / b[i] + 1;
        } else {
            if (1LL * a[i] * m >= mid) {
                cnt += (mid - 1) / a[i] + 1;
            } else {
                cnt += (mid - 1LL * a[i] * m - 1) / b[i] + m + 1;
            }
        }
        if (cnt > 1LL * n * m) {
            return false;
        }
    }
    return true;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    #ifdef ngu
    freopen("test.inp", "r", stdin);
    freopen("test.out", "w", stdout);
    #endif
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }
    long long l = 1, r = 1e18, res = 0;
    while (l <= r) {
        long long mid = l + r >> 1;
        if (check(mid)) {
            res = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    cout << res;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:51:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   51 |         long long mid = l + r >> 1;
      |                         ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 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 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 85 ms 2776 KB Output is correct
12 Correct 91 ms 2760 KB Output is correct
13 Correct 66 ms 2648 KB Output is correct
14 Correct 55 ms 2784 KB Output is correct
15 Correct 1 ms 2512 KB Output is correct
16 Correct 25 ms 3924 KB Output is correct
17 Correct 80 ms 9172 KB Output is correct
18 Correct 82 ms 8544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2512 KB Output is correct
2 Correct 25 ms 3924 KB Output is correct
3 Correct 80 ms 9172 KB Output is correct
4 Correct 82 ms 8544 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 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 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 49 ms 2668 KB Output is correct
14 Correct 28 ms 2656 KB Output is correct
15 Correct 20 ms 2648 KB Output is correct
16 Correct 17 ms 2652 KB Output is correct
17 Correct 1 ms 2396 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 0 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 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 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 85 ms 2776 KB Output is correct
12 Correct 91 ms 2760 KB Output is correct
13 Correct 66 ms 2648 KB Output is correct
14 Correct 55 ms 2784 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 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 49 ms 2668 KB Output is correct
24 Correct 28 ms 2656 KB Output is correct
25 Correct 20 ms 2648 KB Output is correct
26 Correct 17 ms 2652 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 2 ms 2524 KB Output is correct
34 Correct 1 ms 2512 KB Output is correct
35 Correct 25 ms 3924 KB Output is correct
36 Correct 80 ms 9172 KB Output is correct
37 Correct 82 ms 8544 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 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 2396 KB Output is correct
45 Correct 2 ms 2396 KB Output is correct
46 Correct 3 ms 2648 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 16 ms 3688 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 1 ms 2396 KB Output is correct
53 Correct 1 ms 2512 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 45 ms 5336 KB Output is correct
56 Correct 28 ms 3932 KB Output is correct
57 Correct 21 ms 3928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 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 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 49 ms 2668 KB Output is correct
10 Correct 28 ms 2656 KB Output is correct
11 Correct 20 ms 2648 KB Output is correct
12 Correct 17 ms 2652 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 2 ms 2524 KB Output is correct
20 Correct 1 ms 2512 KB Output is correct
21 Correct 25 ms 3924 KB Output is correct
22 Correct 80 ms 9172 KB Output is correct
23 Correct 82 ms 8544 KB Output is correct
24 Correct 27 ms 3416 KB Output is correct
25 Correct 62 ms 5312 KB Output is correct
26 Correct 11 ms 3164 KB Output is correct
27 Correct 84 ms 8384 KB Output is correct
28 Correct 85 ms 8528 KB Output is correct
29 Correct 87 ms 8528 KB Output is correct
30 Correct 109 ms 8380 KB Output is correct
31 Correct 181 ms 8400 KB Output is correct
32 Correct 96 ms 3956 KB Output is correct
33 Correct 220 ms 9036 KB Output is correct
34 Correct 88 ms 3932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 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 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 85 ms 2776 KB Output is correct
12 Correct 91 ms 2760 KB Output is correct
13 Correct 66 ms 2648 KB Output is correct
14 Correct 55 ms 2784 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 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 49 ms 2668 KB Output is correct
24 Correct 28 ms 2656 KB Output is correct
25 Correct 20 ms 2648 KB Output is correct
26 Correct 17 ms 2652 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 2 ms 2524 KB Output is correct
34 Correct 1 ms 2396 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 2396 KB Output is correct
41 Correct 2 ms 2396 KB Output is correct
42 Correct 3 ms 2648 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 16 ms 3688 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 1 ms 2396 KB Output is correct
49 Correct 1 ms 2512 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 45 ms 5336 KB Output is correct
52 Correct 28 ms 3932 KB Output is correct
53 Correct 21 ms 3928 KB Output is correct
54 Correct 27 ms 3416 KB Output is correct
55 Correct 62 ms 5312 KB Output is correct
56 Correct 11 ms 3164 KB Output is correct
57 Correct 84 ms 8384 KB Output is correct
58 Correct 85 ms 8528 KB Output is correct
59 Correct 87 ms 8528 KB Output is correct
60 Correct 109 ms 8380 KB Output is correct
61 Correct 181 ms 8400 KB Output is correct
62 Correct 96 ms 3956 KB Output is correct
63 Correct 220 ms 9036 KB Output is correct
64 Correct 88 ms 3932 KB Output is correct
65 Correct 1 ms 2512 KB Output is correct
66 Correct 25 ms 3924 KB Output is correct
67 Correct 80 ms 9172 KB Output is correct
68 Correct 82 ms 8544 KB Output is correct
69 Correct 19 ms 3160 KB Output is correct
70 Correct 6 ms 2652 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 30 ms 3404 KB Output is correct
73 Correct 6 ms 2652 KB Output is correct
74 Correct 1 ms 2540 KB Output is correct
75 Correct 95 ms 8532 KB Output is correct
76 Correct 102 ms 8736 KB Output is correct
77 Correct 107 ms 8588 KB Output is correct
78 Correct 137 ms 8528 KB Output is correct
79 Correct 189 ms 8392 KB Output is correct
80 Correct 208 ms 8596 KB Output is correct
81 Correct 200 ms 6480 KB Output is correct
82 Correct 198 ms 6484 KB Output is correct