Submission #987731

# Submission time Handle Problem Language Result Execution time Memory
987731 2024-05-23T13:08:10 Z _callmelucian Self Study (JOI22_ho_t2) C++14
100 / 100
232 ms 13940 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tt;

#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())

const int mn = 3e5 + 5;
ll a[mn], b[mn], cur[mn];
ll n, m;

bool ok (ll lb) {
    ll period = n * m;
    for (int i = 0; i < n; i++) {
        cur[i] = 0;
        if (a[i] < b[i]) continue;
        ll need = min(m, lb / a[i] + (lb % a[i] ? 1 : 0));
        cur[i] = need * a[i], period -= need;
    }
    for (int i = 0; i < n; i++) {
        if (cur[i] >= lb) continue;
        ll need = (lb - cur[i]) / b[i] + ((lb - cur[i]) % b[i] ? 1 : 0);
        if (need > period) return 0;
        period -= need;
    }
    return 1;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    ll ans = 0;
    for (ll i = (1LL << 59); i; i >>= 1)
        if (ok((ans | i))) ans |= i;
    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4568 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4652 KB Output is correct
11 Correct 173 ms 13064 KB Output is correct
12 Correct 170 ms 13168 KB Output is correct
13 Correct 80 ms 11296 KB Output is correct
14 Correct 141 ms 11300 KB Output is correct
15 Correct 1 ms 4440 KB Output is correct
16 Correct 188 ms 8532 KB Output is correct
17 Correct 158 ms 13912 KB Output is correct
18 Correct 153 ms 13140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 188 ms 8532 KB Output is correct
3 Correct 158 ms 13912 KB Output is correct
4 Correct 153 ms 13140 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4552 KB Output is correct
8 Correct 1 ms 4696 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 82 ms 9564 KB Output is correct
14 Correct 55 ms 8708 KB Output is correct
15 Correct 41 ms 8024 KB Output is correct
16 Correct 34 ms 7768 KB Output is correct
17 Correct 2 ms 4444 KB Output is correct
18 Correct 2 ms 4700 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4440 KB Output is correct
22 Correct 4 ms 4440 KB Output is correct
23 Correct 4 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4568 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4652 KB Output is correct
11 Correct 173 ms 13064 KB Output is correct
12 Correct 170 ms 13168 KB Output is correct
13 Correct 80 ms 11296 KB Output is correct
14 Correct 141 ms 11300 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4552 KB Output is correct
18 Correct 1 ms 4696 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 82 ms 9564 KB Output is correct
24 Correct 55 ms 8708 KB Output is correct
25 Correct 41 ms 8024 KB Output is correct
26 Correct 34 ms 7768 KB Output is correct
27 Correct 2 ms 4444 KB Output is correct
28 Correct 2 ms 4700 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4440 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 4 ms 4440 KB Output is correct
33 Correct 4 ms 4700 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 188 ms 8532 KB Output is correct
36 Correct 158 ms 13912 KB Output is correct
37 Correct 153 ms 13140 KB Output is correct
38 Correct 1 ms 4440 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4440 KB Output is correct
42 Correct 1 ms 4440 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4564 KB Output is correct
45 Correct 4 ms 4700 KB Output is correct
46 Correct 6 ms 4700 KB Output is correct
47 Correct 2 ms 4444 KB Output is correct
48 Correct 33 ms 7768 KB Output is correct
49 Correct 1 ms 4440 KB Output is correct
50 Correct 2 ms 4444 KB Output is correct
51 Correct 4 ms 4444 KB Output is correct
52 Correct 1 ms 4444 KB Output is correct
53 Correct 1 ms 4444 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 86 ms 9564 KB Output is correct
56 Correct 31 ms 8024 KB Output is correct
57 Correct 49 ms 8028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4552 KB Output is correct
4 Correct 1 ms 4696 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 82 ms 9564 KB Output is correct
10 Correct 55 ms 8708 KB Output is correct
11 Correct 41 ms 8024 KB Output is correct
12 Correct 34 ms 7768 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 2 ms 4700 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 4 ms 4440 KB Output is correct
19 Correct 4 ms 4700 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 188 ms 8532 KB Output is correct
22 Correct 158 ms 13912 KB Output is correct
23 Correct 153 ms 13140 KB Output is correct
24 Correct 35 ms 7512 KB Output is correct
25 Correct 90 ms 9208 KB Output is correct
26 Correct 22 ms 7256 KB Output is correct
27 Correct 170 ms 13292 KB Output is correct
28 Correct 161 ms 13288 KB Output is correct
29 Correct 162 ms 13140 KB Output is correct
30 Correct 180 ms 13136 KB Output is correct
31 Correct 226 ms 13288 KB Output is correct
32 Correct 207 ms 8652 KB Output is correct
33 Correct 219 ms 13940 KB Output is correct
34 Correct 232 ms 8536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4568 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4652 KB Output is correct
11 Correct 173 ms 13064 KB Output is correct
12 Correct 170 ms 13168 KB Output is correct
13 Correct 80 ms 11296 KB Output is correct
14 Correct 141 ms 11300 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4552 KB Output is correct
18 Correct 1 ms 4696 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4440 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 82 ms 9564 KB Output is correct
24 Correct 55 ms 8708 KB Output is correct
25 Correct 41 ms 8024 KB Output is correct
26 Correct 34 ms 7768 KB Output is correct
27 Correct 2 ms 4444 KB Output is correct
28 Correct 2 ms 4700 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4440 KB Output is correct
31 Correct 1 ms 4440 KB Output is correct
32 Correct 4 ms 4440 KB Output is correct
33 Correct 4 ms 4700 KB Output is correct
34 Correct 1 ms 4440 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4440 KB Output is correct
38 Correct 1 ms 4440 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4564 KB Output is correct
41 Correct 4 ms 4700 KB Output is correct
42 Correct 6 ms 4700 KB Output is correct
43 Correct 2 ms 4444 KB Output is correct
44 Correct 33 ms 7768 KB Output is correct
45 Correct 1 ms 4440 KB Output is correct
46 Correct 2 ms 4444 KB Output is correct
47 Correct 4 ms 4444 KB Output is correct
48 Correct 1 ms 4444 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 86 ms 9564 KB Output is correct
52 Correct 31 ms 8024 KB Output is correct
53 Correct 49 ms 8028 KB Output is correct
54 Correct 35 ms 7512 KB Output is correct
55 Correct 90 ms 9208 KB Output is correct
56 Correct 22 ms 7256 KB Output is correct
57 Correct 170 ms 13292 KB Output is correct
58 Correct 161 ms 13288 KB Output is correct
59 Correct 162 ms 13140 KB Output is correct
60 Correct 180 ms 13136 KB Output is correct
61 Correct 226 ms 13288 KB Output is correct
62 Correct 207 ms 8652 KB Output is correct
63 Correct 219 ms 13940 KB Output is correct
64 Correct 232 ms 8536 KB Output is correct
65 Correct 1 ms 4440 KB Output is correct
66 Correct 188 ms 8532 KB Output is correct
67 Correct 158 ms 13912 KB Output is correct
68 Correct 153 ms 13140 KB Output is correct
69 Correct 23 ms 7260 KB Output is correct
70 Correct 7 ms 4700 KB Output is correct
71 Correct 1 ms 4444 KB Output is correct
72 Correct 32 ms 7516 KB Output is correct
73 Correct 8 ms 4696 KB Output is correct
74 Correct 2 ms 4444 KB Output is correct
75 Correct 173 ms 13248 KB Output is correct
76 Correct 178 ms 13292 KB Output is correct
77 Correct 187 ms 13176 KB Output is correct
78 Correct 195 ms 13136 KB Output is correct
79 Correct 216 ms 13292 KB Output is correct
80 Correct 221 ms 13140 KB Output is correct
81 Correct 212 ms 11300 KB Output is correct
82 Correct 205 ms 11100 KB Output is correct