Submission #528776

# Submission time Handle Problem Language Result Execution time Memory
528776 2022-02-21T11:36:25 Z FireGhost1301 Self Study (JOI22_ho_t2) C++11
100 / 100
239 ms 7212 KB
#include <bits/stdc++.h>
using namespace std;

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

bool check(long long d) {
    long long sum = 0;
    for (int i = 1; i <= n; ++i) {
        long long x = d;
        long long k = (x + a[i] - 1) / a[i];
        k = min(k, (long long)m);
        x -= k * a[i];
        sum += k;
        if (x > 0) sum += (x + b[i] - 1) / b[i];
        if (sum > 1LL * n * m) return 0;
    }
    return 1;
}

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], a[i] = max(a[i], b[i]);
    long long l = 1, r = 1e18 + 7, ans = 0, mid;
    while (l <= r) {
        mid = (l + r) >> 1;
        if (check(mid)) ans = mid, l = mid + 1;
        else r = mid - 1;
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 93 ms 2564 KB Output is correct
12 Correct 101 ms 2824 KB Output is correct
13 Correct 98 ms 2628 KB Output is correct
14 Correct 89 ms 2612 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 34 ms 2880 KB Output is correct
17 Correct 116 ms 3432 KB Output is correct
18 Correct 95 ms 3780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 34 ms 2880 KB Output is correct
3 Correct 116 ms 3432 KB Output is correct
4 Correct 95 ms 3780 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 51 ms 1420 KB Output is correct
14 Correct 36 ms 1100 KB Output is correct
15 Correct 23 ms 916 KB Output is correct
16 Correct 22 ms 716 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 3 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 93 ms 2564 KB Output is correct
12 Correct 101 ms 2824 KB Output is correct
13 Correct 98 ms 2628 KB Output is correct
14 Correct 89 ms 2612 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 51 ms 1420 KB Output is correct
24 Correct 36 ms 1100 KB Output is correct
25 Correct 23 ms 916 KB Output is correct
26 Correct 22 ms 716 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 3 ms 432 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 34 ms 2880 KB Output is correct
36 Correct 116 ms 3432 KB Output is correct
37 Correct 95 ms 3780 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 316 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 3 ms 332 KB Output is correct
46 Correct 4 ms 464 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 20 ms 1232 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 0 ms 204 KB Output is correct
51 Correct 3 ms 332 KB Output is correct
52 Correct 1 ms 316 KB Output is correct
53 Correct 0 ms 204 KB Output is correct
54 Correct 0 ms 332 KB Output is correct
55 Correct 55 ms 3136 KB Output is correct
56 Correct 38 ms 1672 KB Output is correct
57 Correct 27 ms 1732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 51 ms 1420 KB Output is correct
10 Correct 36 ms 1100 KB Output is correct
11 Correct 23 ms 916 KB Output is correct
12 Correct 22 ms 716 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 3 ms 432 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 34 ms 2880 KB Output is correct
22 Correct 116 ms 3432 KB Output is correct
23 Correct 95 ms 3780 KB Output is correct
24 Correct 33 ms 976 KB Output is correct
25 Correct 77 ms 2240 KB Output is correct
26 Correct 14 ms 708 KB Output is correct
27 Correct 97 ms 4360 KB Output is correct
28 Correct 111 ms 6592 KB Output is correct
29 Correct 110 ms 5176 KB Output is correct
30 Correct 136 ms 4492 KB Output is correct
31 Correct 210 ms 5572 KB Output is correct
32 Correct 148 ms 3156 KB Output is correct
33 Correct 239 ms 4420 KB Output is correct
34 Correct 164 ms 2704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 93 ms 2564 KB Output is correct
12 Correct 101 ms 2824 KB Output is correct
13 Correct 98 ms 2628 KB Output is correct
14 Correct 89 ms 2612 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 51 ms 1420 KB Output is correct
24 Correct 36 ms 1100 KB Output is correct
25 Correct 23 ms 916 KB Output is correct
26 Correct 22 ms 716 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 3 ms 432 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 316 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 3 ms 332 KB Output is correct
42 Correct 4 ms 464 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 20 ms 1232 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 3 ms 332 KB Output is correct
48 Correct 1 ms 316 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 0 ms 332 KB Output is correct
51 Correct 55 ms 3136 KB Output is correct
52 Correct 38 ms 1672 KB Output is correct
53 Correct 27 ms 1732 KB Output is correct
54 Correct 33 ms 976 KB Output is correct
55 Correct 77 ms 2240 KB Output is correct
56 Correct 14 ms 708 KB Output is correct
57 Correct 97 ms 4360 KB Output is correct
58 Correct 111 ms 6592 KB Output is correct
59 Correct 110 ms 5176 KB Output is correct
60 Correct 136 ms 4492 KB Output is correct
61 Correct 210 ms 5572 KB Output is correct
62 Correct 148 ms 3156 KB Output is correct
63 Correct 239 ms 4420 KB Output is correct
64 Correct 164 ms 2704 KB Output is correct
65 Correct 0 ms 204 KB Output is correct
66 Correct 34 ms 2880 KB Output is correct
67 Correct 116 ms 3432 KB Output is correct
68 Correct 95 ms 3780 KB Output is correct
69 Correct 24 ms 708 KB Output is correct
70 Correct 7 ms 332 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 34 ms 844 KB Output is correct
73 Correct 8 ms 460 KB Output is correct
74 Correct 1 ms 452 KB Output is correct
75 Correct 111 ms 4780 KB Output is correct
76 Correct 124 ms 5700 KB Output is correct
77 Correct 138 ms 6444 KB Output is correct
78 Correct 174 ms 3012 KB Output is correct
79 Correct 239 ms 4384 KB Output is correct
80 Correct 238 ms 7212 KB Output is correct
81 Correct 219 ms 4256 KB Output is correct
82 Correct 217 ms 4488 KB Output is correct