Submission #879935

# Submission time Handle Problem Language Result Execution time Memory
879935 2023-11-28T11:16:50 Z frostray8653 Self Study (JOI22_ho_t2) C++17
100 / 100
381 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];

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

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 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 2404 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2464 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 99 ms 5068 KB Output is correct
12 Correct 90 ms 5068 KB Output is correct
13 Correct 96 ms 5132 KB Output is correct
14 Correct 145 ms 5132 KB Output is correct
15 Correct 0 ms 2392 KB Output is correct
16 Correct 65 ms 5076 KB Output is correct
17 Correct 138 ms 5128 KB Output is correct
18 Correct 66 ms 5200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 65 ms 5076 KB Output is correct
3 Correct 138 ms 5128 KB Output is correct
4 Correct 66 ms 5200 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 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 51 ms 4724 KB Output is correct
14 Correct 35 ms 4700 KB Output is correct
15 Correct 25 ms 4696 KB Output is correct
16 Correct 25 ms 4800 KB Output is correct
17 Correct 1 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 1 ms 2396 KB Output is correct
23 Correct 3 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 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 2404 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2464 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 99 ms 5068 KB Output is correct
12 Correct 90 ms 5068 KB Output is correct
13 Correct 96 ms 5132 KB Output is correct
14 Correct 145 ms 5132 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 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 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 51 ms 4724 KB Output is correct
24 Correct 35 ms 4700 KB Output is correct
25 Correct 25 ms 4696 KB Output is correct
26 Correct 25 ms 4800 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
29 Correct 0 ms 2396 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 2396 KB Output is correct
33 Correct 3 ms 2396 KB Output is correct
34 Correct 0 ms 2392 KB Output is correct
35 Correct 65 ms 5076 KB Output is correct
36 Correct 138 ms 5128 KB Output is correct
37 Correct 66 ms 5200 KB Output is correct
38 Correct 0 ms 2392 KB Output is correct
39 Correct 1 ms 2392 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 0 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 4 ms 2584 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 23 ms 4700 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 3 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 0 ms 2396 KB Output is correct
55 Correct 66 ms 4700 KB Output is correct
56 Correct 35 ms 4700 KB Output is correct
57 Correct 51 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 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 51 ms 4724 KB Output is correct
10 Correct 35 ms 4700 KB Output is correct
11 Correct 25 ms 4696 KB Output is correct
12 Correct 25 ms 4800 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 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 2396 KB Output is correct
19 Correct 3 ms 2396 KB Output is correct
20 Correct 0 ms 2392 KB Output is correct
21 Correct 65 ms 5076 KB Output is correct
22 Correct 138 ms 5128 KB Output is correct
23 Correct 66 ms 5200 KB Output is correct
24 Correct 37 ms 4696 KB Output is correct
25 Correct 87 ms 4700 KB Output is correct
26 Correct 15 ms 4696 KB Output is correct
27 Correct 86 ms 4956 KB Output is correct
28 Correct 107 ms 5132 KB Output is correct
29 Correct 116 ms 5132 KB Output is correct
30 Correct 152 ms 5132 KB Output is correct
31 Correct 262 ms 5136 KB Output is correct
32 Correct 185 ms 4952 KB Output is correct
33 Correct 354 ms 4956 KB Output is correct
34 Correct 192 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 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 2404 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2464 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 99 ms 5068 KB Output is correct
12 Correct 90 ms 5068 KB Output is correct
13 Correct 96 ms 5132 KB Output is correct
14 Correct 145 ms 5132 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 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 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 51 ms 4724 KB Output is correct
24 Correct 35 ms 4700 KB Output is correct
25 Correct 25 ms 4696 KB Output is correct
26 Correct 25 ms 4800 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
29 Correct 0 ms 2396 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 2396 KB Output is correct
33 Correct 3 ms 2396 KB Output is correct
34 Correct 0 ms 2392 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 0 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 4 ms 2584 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 23 ms 4700 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 3 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 0 ms 2396 KB Output is correct
51 Correct 66 ms 4700 KB Output is correct
52 Correct 35 ms 4700 KB Output is correct
53 Correct 51 ms 4700 KB Output is correct
54 Correct 37 ms 4696 KB Output is correct
55 Correct 87 ms 4700 KB Output is correct
56 Correct 15 ms 4696 KB Output is correct
57 Correct 86 ms 4956 KB Output is correct
58 Correct 107 ms 5132 KB Output is correct
59 Correct 116 ms 5132 KB Output is correct
60 Correct 152 ms 5132 KB Output is correct
61 Correct 262 ms 5136 KB Output is correct
62 Correct 185 ms 4952 KB Output is correct
63 Correct 354 ms 4956 KB Output is correct
64 Correct 192 ms 4956 KB Output is correct
65 Correct 0 ms 2392 KB Output is correct
66 Correct 65 ms 5076 KB Output is correct
67 Correct 138 ms 5128 KB Output is correct
68 Correct 66 ms 5200 KB Output is correct
69 Correct 29 ms 4700 KB Output is correct
70 Correct 8 ms 2396 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 43 ms 4724 KB Output is correct
73 Correct 9 ms 2392 KB Output is correct
74 Correct 1 ms 2396 KB Output is correct
75 Correct 134 ms 5128 KB Output is correct
76 Correct 152 ms 4944 KB Output is correct
77 Correct 174 ms 5132 KB Output is correct
78 Correct 209 ms 5128 KB Output is correct
79 Correct 288 ms 4944 KB Output is correct
80 Correct 294 ms 4956 KB Output is correct
81 Correct 276 ms 5076 KB Output is correct
82 Correct 381 ms 5136 KB Output is correct