답안 #921490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
921490 2024-02-04T02:43:59 Z LiuBruh Self Study (JOI22_ho_t2) C++17
100 / 100
210 ms 11604 KB
#include <bits/stdc++.h>

#define int long long
#define sz(v) (int)v.size()
using namespace std;

const int maxn = (int)3e5 + 5;
const int INF = (int)1e18 + 5;

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

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

void solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    for (int i = 1; i <= n; i++) a[i] = max(a[i], b[i]);

    int l = 1, r = (int)2e18, mid;
    while (l < r) {
        mid = (l + r + 1) / 2;
        if (check(mid)) l = mid;
        else r = mid - 1;
    }
    cout << l << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 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 1 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 3 ms 2396 KB Output is correct
11 Correct 149 ms 5128 KB Output is correct
12 Correct 144 ms 5132 KB Output is correct
13 Correct 133 ms 4952 KB Output is correct
14 Correct 184 ms 4956 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 181 ms 5132 KB Output is correct
17 Correct 144 ms 5200 KB Output is correct
18 Correct 147 ms 5132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 181 ms 5132 KB Output is correct
3 Correct 144 ms 5200 KB Output is correct
4 Correct 147 ms 5132 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 1 ms 2392 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 1 ms 2396 KB Output is correct
13 Correct 79 ms 4728 KB Output is correct
14 Correct 49 ms 4564 KB Output is correct
15 Correct 37 ms 4700 KB Output is correct
16 Correct 30 ms 4696 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 3 ms 2392 KB Output is correct
23 Correct 3 ms 2392 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 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 1 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 3 ms 2396 KB Output is correct
11 Correct 149 ms 5128 KB Output is correct
12 Correct 144 ms 5132 KB Output is correct
13 Correct 133 ms 4952 KB Output is correct
14 Correct 184 ms 4956 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 2396 KB Output is correct
18 Correct 1 ms 2392 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 1 ms 2396 KB Output is correct
23 Correct 79 ms 4728 KB Output is correct
24 Correct 49 ms 4564 KB Output is correct
25 Correct 37 ms 4700 KB Output is correct
26 Correct 30 ms 4696 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 3 ms 2392 KB Output is correct
33 Correct 3 ms 2392 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 181 ms 5132 KB Output is correct
36 Correct 144 ms 5200 KB Output is correct
37 Correct 147 ms 5132 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 2648 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 3 ms 2396 KB Output is correct
46 Correct 6 ms 2816 KB Output is correct
47 Correct 1 ms 2392 KB Output is correct
48 Correct 26 ms 4720 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2392 KB Output is correct
51 Correct 3 ms 2648 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2648 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 72 ms 4700 KB Output is correct
56 Correct 47 ms 4696 KB Output is correct
57 Correct 62 ms 4696 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 2396 KB Output is correct
4 Correct 1 ms 2392 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 1 ms 2396 KB Output is correct
9 Correct 79 ms 4728 KB Output is correct
10 Correct 49 ms 4564 KB Output is correct
11 Correct 37 ms 4700 KB Output is correct
12 Correct 30 ms 4696 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 3 ms 2392 KB Output is correct
19 Correct 3 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 181 ms 5132 KB Output is correct
22 Correct 144 ms 5200 KB Output is correct
23 Correct 147 ms 5132 KB Output is correct
24 Correct 29 ms 4952 KB Output is correct
25 Correct 77 ms 4724 KB Output is correct
26 Correct 17 ms 4700 KB Output is correct
27 Correct 157 ms 5128 KB Output is correct
28 Correct 144 ms 4956 KB Output is correct
29 Correct 146 ms 5132 KB Output is correct
30 Correct 155 ms 4952 KB Output is correct
31 Correct 193 ms 5136 KB Output is correct
32 Correct 192 ms 6304 KB Output is correct
33 Correct 210 ms 11604 KB Output is correct
34 Correct 186 ms 6312 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 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 1 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 3 ms 2396 KB Output is correct
11 Correct 149 ms 5128 KB Output is correct
12 Correct 144 ms 5132 KB Output is correct
13 Correct 133 ms 4952 KB Output is correct
14 Correct 184 ms 4956 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 2396 KB Output is correct
18 Correct 1 ms 2392 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 1 ms 2396 KB Output is correct
23 Correct 79 ms 4728 KB Output is correct
24 Correct 49 ms 4564 KB Output is correct
25 Correct 37 ms 4700 KB Output is correct
26 Correct 30 ms 4696 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 3 ms 2392 KB Output is correct
33 Correct 3 ms 2392 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 2648 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 3 ms 2396 KB Output is correct
42 Correct 6 ms 2816 KB Output is correct
43 Correct 1 ms 2392 KB Output is correct
44 Correct 26 ms 4720 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 3 ms 2648 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2648 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 72 ms 4700 KB Output is correct
52 Correct 47 ms 4696 KB Output is correct
53 Correct 62 ms 4696 KB Output is correct
54 Correct 29 ms 4952 KB Output is correct
55 Correct 77 ms 4724 KB Output is correct
56 Correct 17 ms 4700 KB Output is correct
57 Correct 157 ms 5128 KB Output is correct
58 Correct 144 ms 4956 KB Output is correct
59 Correct 146 ms 5132 KB Output is correct
60 Correct 155 ms 4952 KB Output is correct
61 Correct 193 ms 5136 KB Output is correct
62 Correct 192 ms 6304 KB Output is correct
63 Correct 210 ms 11604 KB Output is correct
64 Correct 186 ms 6312 KB Output is correct
65 Correct 1 ms 2392 KB Output is correct
66 Correct 181 ms 5132 KB Output is correct
67 Correct 144 ms 5200 KB Output is correct
68 Correct 147 ms 5132 KB Output is correct
69 Correct 21 ms 5212 KB Output is correct
70 Correct 7 ms 2648 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 30 ms 5440 KB Output is correct
73 Correct 7 ms 2652 KB Output is correct
74 Correct 1 ms 2536 KB Output is correct
75 Correct 149 ms 10828 KB Output is correct
76 Correct 153 ms 10836 KB Output is correct
77 Correct 157 ms 10868 KB Output is correct
78 Correct 172 ms 10940 KB Output is correct
79 Correct 197 ms 10832 KB Output is correct
80 Correct 203 ms 10944 KB Output is correct
81 Correct 198 ms 8788 KB Output is correct
82 Correct 196 ms 8788 KB Output is correct