답안 #1092638

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1092638 2024-09-24T16:19:28 Z ortsac Self Study (JOI22_ho_t2) C++17
100 / 100
277 ms 13916 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int MAXN = 3e5 + 10;
int a[MAXN], b[MAXN];
int n, m;

bool check(int x) {
    int rem = 0;
    vector<int> need(n);
    for (int i = 0; i < n; i++) {
        int qtd = ((x + a[i] - 1)/a[i]);
        if (qtd > m) need[i] = (x - m*a[i]);
        else rem += (m - qtd);
    }
    for (int i = 0; i < n; i++) {
        int qtd = ((need[i] + b[i] - 1)/b[i]);
        rem -= qtd;
        if (rem < 0) return 0;
    }
    return 1;
}

int32_t main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        a[i] = max(a[i], b[i]);
    }
    int l = 0, r = 1e18, ans;
    while (l <= r) {
        int m = (l+r)/2;
        if (check(m)) {
            ans = m;
            l = m + 1;
        } else {
            r = m - 1;
        }
    }
    cout << ans << "\n";
}
# 결과 실행 시간 메모리 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 3 ms 604 KB Output is correct
11 Correct 206 ms 13112 KB Output is correct
12 Correct 226 ms 13140 KB Output is correct
13 Correct 192 ms 11088 KB Output is correct
14 Correct 163 ms 11088 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 96 ms 8648 KB Output is correct
17 Correct 277 ms 13916 KB Output is correct
18 Correct 207 ms 13148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 96 ms 8648 KB Output is correct
3 Correct 277 ms 13916 KB Output is correct
4 Correct 207 ms 13148 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 356 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 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 108 ms 6852 KB Output is correct
14 Correct 74 ms 4688 KB Output is correct
15 Correct 53 ms 3592 KB Output is correct
16 Correct 44 ms 2940 KB Output is correct
17 Correct 1 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 2 ms 348 KB Output is correct
23 Correct 4 ms 584 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 3 ms 604 KB Output is correct
11 Correct 206 ms 13112 KB Output is correct
12 Correct 226 ms 13140 KB Output is correct
13 Correct 192 ms 11088 KB Output is correct
14 Correct 163 ms 11088 KB Output is correct
15 Correct 0 ms 356 KB Output is correct
16 Correct 0 ms 356 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 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 108 ms 6852 KB Output is correct
24 Correct 74 ms 4688 KB Output is correct
25 Correct 53 ms 3592 KB Output is correct
26 Correct 44 ms 2940 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 4 ms 584 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 96 ms 8648 KB Output is correct
36 Correct 277 ms 13916 KB Output is correct
37 Correct 207 ms 13148 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 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 1 ms 348 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 4 ms 604 KB Output is correct
46 Correct 8 ms 604 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 40 ms 2536 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
50 Correct 0 ms 352 KB Output is correct
51 Correct 4 ms 860 KB Output is correct
52 Correct 0 ms 356 KB Output is correct
53 Correct 0 ms 352 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 107 ms 6700 KB Output is correct
56 Correct 54 ms 3924 KB Output is correct
57 Correct 54 ms 3932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 356 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 108 ms 6852 KB Output is correct
10 Correct 74 ms 4688 KB Output is correct
11 Correct 53 ms 3592 KB Output is correct
12 Correct 44 ms 2940 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 4 ms 584 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 96 ms 8648 KB Output is correct
22 Correct 277 ms 13916 KB Output is correct
23 Correct 207 ms 13148 KB Output is correct
24 Correct 38 ms 2396 KB Output is correct
25 Correct 106 ms 5972 KB Output is correct
26 Correct 24 ms 1636 KB Output is correct
27 Correct 220 ms 13260 KB Output is correct
28 Correct 230 ms 13140 KB Output is correct
29 Correct 227 ms 13152 KB Output is correct
30 Correct 234 ms 13076 KB Output is correct
31 Correct 240 ms 13136 KB Output is correct
32 Correct 105 ms 8636 KB Output is correct
33 Correct 252 ms 13812 KB Output is correct
34 Correct 109 ms 8532 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 3 ms 604 KB Output is correct
11 Correct 206 ms 13112 KB Output is correct
12 Correct 226 ms 13140 KB Output is correct
13 Correct 192 ms 11088 KB Output is correct
14 Correct 163 ms 11088 KB Output is correct
15 Correct 0 ms 356 KB Output is correct
16 Correct 0 ms 356 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 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 108 ms 6852 KB Output is correct
24 Correct 74 ms 4688 KB Output is correct
25 Correct 53 ms 3592 KB Output is correct
26 Correct 44 ms 2940 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 4 ms 584 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 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 1 ms 348 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 4 ms 604 KB Output is correct
42 Correct 8 ms 604 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 40 ms 2536 KB Output is correct
45 Correct 0 ms 352 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 4 ms 860 KB Output is correct
48 Correct 0 ms 356 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 107 ms 6700 KB Output is correct
52 Correct 54 ms 3924 KB Output is correct
53 Correct 54 ms 3932 KB Output is correct
54 Correct 38 ms 2396 KB Output is correct
55 Correct 106 ms 5972 KB Output is correct
56 Correct 24 ms 1636 KB Output is correct
57 Correct 220 ms 13260 KB Output is correct
58 Correct 230 ms 13140 KB Output is correct
59 Correct 227 ms 13152 KB Output is correct
60 Correct 234 ms 13076 KB Output is correct
61 Correct 240 ms 13136 KB Output is correct
62 Correct 105 ms 8636 KB Output is correct
63 Correct 252 ms 13812 KB Output is correct
64 Correct 109 ms 8532 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 96 ms 8648 KB Output is correct
67 Correct 277 ms 13916 KB Output is correct
68 Correct 207 ms 13148 KB Output is correct
69 Correct 26 ms 1624 KB Output is correct
70 Correct 7 ms 600 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 35 ms 2288 KB Output is correct
73 Correct 8 ms 856 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 219 ms 13144 KB Output is correct
76 Correct 225 ms 13076 KB Output is correct
77 Correct 226 ms 13136 KB Output is correct
78 Correct 251 ms 13096 KB Output is correct
79 Correct 272 ms 13352 KB Output is correct
80 Correct 250 ms 13252 KB Output is correct
81 Correct 193 ms 11088 KB Output is correct
82 Correct 192 ms 11088 KB Output is correct