답안 #879936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879936 2023-11-28T11:17:26 Z frostray8653 Self Study (JOI22_ho_t2) C++17
100 / 100
382 ms 5200 KB
#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
using pii = pair<int, int>;
const int N = 300005;
const int INF = 2e18;
int n, m;
int a[N], b[N];

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

signed main() {
    IO;
    cin >> n >> m;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n) cin >> b[i];

    int l = 0, r = 10000;
    while (check(r))
        r *= 2;
    while (l + 1 < r) {
        int mid = (l + r) >> 1;
        if (check(mid))
            l = mid;
        else
            r = mid;
    }
    cout << l << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 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 0 ms 2396 KB Output is correct
6 Correct 0 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 0 ms 2396 KB Output is correct
10 Correct 2 ms 2392 KB Output is correct
11 Correct 96 ms 5132 KB Output is correct
12 Correct 88 ms 4948 KB Output is correct
13 Correct 95 ms 4956 KB Output is correct
14 Correct 142 ms 4956 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 65 ms 5076 KB Output is correct
17 Correct 138 ms 4944 KB Output is correct
18 Correct 62 ms 5072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 65 ms 5076 KB Output is correct
3 Correct 138 ms 4944 KB Output is correct
4 Correct 62 ms 5072 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2508 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 50 ms 4700 KB Output is correct
14 Correct 36 ms 4700 KB Output is correct
15 Correct 25 ms 4568 KB Output is correct
16 Correct 23 ms 4700 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2592 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 1 ms 2648 KB Output is correct
23 Correct 3 ms 2552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 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 0 ms 2396 KB Output is correct
6 Correct 0 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 0 ms 2396 KB Output is correct
10 Correct 2 ms 2392 KB Output is correct
11 Correct 96 ms 5132 KB Output is correct
12 Correct 88 ms 4948 KB Output is correct
13 Correct 95 ms 4956 KB Output is correct
14 Correct 142 ms 4956 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2508 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 50 ms 4700 KB Output is correct
24 Correct 36 ms 4700 KB Output is correct
25 Correct 25 ms 4568 KB Output is correct
26 Correct 23 ms 4700 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2592 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 1 ms 2648 KB Output is correct
33 Correct 3 ms 2552 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 65 ms 5076 KB Output is correct
36 Correct 138 ms 4944 KB Output is correct
37 Correct 62 ms 5072 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 0 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 3 ms 2396 KB Output is correct
46 Correct 4 ms 2392 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 23 ms 4700 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Correct 1 ms 2516 KB Output is correct
51 Correct 2 ms 2396 KB Output is correct
52 Correct 0 ms 2396 KB Output is correct
53 Correct 0 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 70 ms 4696 KB Output is correct
56 Correct 36 ms 4696 KB Output is correct
57 Correct 51 ms 4720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2508 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 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 50 ms 4700 KB Output is correct
10 Correct 36 ms 4700 KB Output is correct
11 Correct 25 ms 4568 KB Output is correct
12 Correct 23 ms 4700 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2592 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2648 KB Output is correct
19 Correct 3 ms 2552 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 65 ms 5076 KB Output is correct
22 Correct 138 ms 4944 KB Output is correct
23 Correct 62 ms 5072 KB Output is correct
24 Correct 37 ms 4700 KB Output is correct
25 Correct 89 ms 4700 KB Output is correct
26 Correct 15 ms 4700 KB Output is correct
27 Correct 86 ms 5140 KB Output is correct
28 Correct 118 ms 5068 KB Output is correct
29 Correct 111 ms 5064 KB Output is correct
30 Correct 147 ms 5064 KB Output is correct
31 Correct 264 ms 4948 KB Output is correct
32 Correct 188 ms 5132 KB Output is correct
33 Correct 354 ms 5200 KB Output is correct
34 Correct 194 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 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 0 ms 2396 KB Output is correct
6 Correct 0 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 0 ms 2396 KB Output is correct
10 Correct 2 ms 2392 KB Output is correct
11 Correct 96 ms 5132 KB Output is correct
12 Correct 88 ms 4948 KB Output is correct
13 Correct 95 ms 4956 KB Output is correct
14 Correct 142 ms 4956 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2508 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 50 ms 4700 KB Output is correct
24 Correct 36 ms 4700 KB Output is correct
25 Correct 25 ms 4568 KB Output is correct
26 Correct 23 ms 4700 KB Output is correct
27 Correct 1 ms 2392 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2592 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 1 ms 2648 KB Output is correct
33 Correct 3 ms 2552 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 0 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 3 ms 2396 KB Output is correct
42 Correct 4 ms 2392 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 23 ms 4700 KB Output is correct
45 Correct 0 ms 2396 KB Output is correct
46 Correct 1 ms 2516 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 0 ms 2396 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 70 ms 4696 KB Output is correct
52 Correct 36 ms 4696 KB Output is correct
53 Correct 51 ms 4720 KB Output is correct
54 Correct 37 ms 4700 KB Output is correct
55 Correct 89 ms 4700 KB Output is correct
56 Correct 15 ms 4700 KB Output is correct
57 Correct 86 ms 5140 KB Output is correct
58 Correct 118 ms 5068 KB Output is correct
59 Correct 111 ms 5064 KB Output is correct
60 Correct 147 ms 5064 KB Output is correct
61 Correct 264 ms 4948 KB Output is correct
62 Correct 188 ms 5132 KB Output is correct
63 Correct 354 ms 5200 KB Output is correct
64 Correct 194 ms 4956 KB Output is correct
65 Correct 0 ms 2396 KB Output is correct
66 Correct 65 ms 5076 KB Output is correct
67 Correct 138 ms 4944 KB Output is correct
68 Correct 62 ms 5072 KB Output is correct
69 Correct 29 ms 4696 KB Output is correct
70 Correct 8 ms 2572 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 43 ms 4564 KB Output is correct
73 Correct 9 ms 2392 KB Output is correct
74 Correct 1 ms 2396 KB Output is correct
75 Correct 137 ms 5132 KB Output is correct
76 Correct 152 ms 4948 KB Output is correct
77 Correct 166 ms 5140 KB Output is correct
78 Correct 212 ms 5132 KB Output is correct
79 Correct 286 ms 5128 KB Output is correct
80 Correct 294 ms 5132 KB Output is correct
81 Correct 277 ms 5136 KB Output is correct
82 Correct 382 ms 5132 KB Output is correct