Submission #527528

# Submission time Handle Problem Language Result Execution time Memory
527528 2022-02-17T14:46:24 Z voventa Self Study (JOI22_ho_t2) C++17
100 / 100
258 ms 9628 KB
#include <bits/stdc++.h>
#define x first
#define y second
#define sz(a) (int)a.size()
#define pb push_back
#define int long long

using namespace std;
typedef long long ll;

void solve();

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

int a[300010], b[300010];

int n, m;

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

void solve() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    int l = 0, r = 2e18;
    while (r - l > 1) {
        int mid = (r + l) / 2;
        if (check(mid))
            l = mid;
        else
            r = mid;
    }
    cout << l << endl;

}
//923953850098595069
//890909762780980010

# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 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 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 101 ms 4896 KB Output is correct
12 Correct 112 ms 4936 KB Output is correct
13 Correct 85 ms 4988 KB Output is correct
14 Correct 84 ms 4956 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 31 ms 4932 KB Output is correct
17 Correct 102 ms 4968 KB Output is correct
18 Correct 91 ms 4992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 31 ms 4932 KB Output is correct
3 Correct 102 ms 4968 KB Output is correct
4 Correct 91 ms 4992 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 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 52 ms 2660 KB Output is correct
14 Correct 33 ms 1868 KB Output is correct
15 Correct 25 ms 1420 KB Output is correct
16 Correct 20 ms 1268 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 296 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 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 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 101 ms 4896 KB Output is correct
12 Correct 112 ms 4936 KB Output is correct
13 Correct 85 ms 4988 KB Output is correct
14 Correct 84 ms 4956 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 52 ms 2660 KB Output is correct
24 Correct 33 ms 1868 KB Output is correct
25 Correct 25 ms 1420 KB Output is correct
26 Correct 20 ms 1268 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 296 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 31 ms 4932 KB Output is correct
36 Correct 102 ms 4968 KB Output is correct
37 Correct 91 ms 4992 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 2 ms 332 KB Output is correct
46 Correct 4 ms 460 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 24 ms 1100 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 2 ms 332 KB Output is correct
52 Correct 0 ms 204 KB Output is correct
53 Correct 0 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 52 ms 2628 KB Output is correct
56 Correct 34 ms 1824 KB Output is correct
57 Correct 33 ms 1808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 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 52 ms 2660 KB Output is correct
10 Correct 33 ms 1868 KB Output is correct
11 Correct 25 ms 1420 KB Output is correct
12 Correct 20 ms 1268 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 3 ms 332 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 31 ms 4932 KB Output is correct
22 Correct 102 ms 4968 KB Output is correct
23 Correct 91 ms 4992 KB Output is correct
24 Correct 32 ms 1052 KB Output is correct
25 Correct 72 ms 2404 KB Output is correct
26 Correct 12 ms 716 KB Output is correct
27 Correct 89 ms 4996 KB Output is correct
28 Correct 102 ms 4992 KB Output is correct
29 Correct 112 ms 4876 KB Output is correct
30 Correct 130 ms 5064 KB Output is correct
31 Correct 205 ms 4992 KB Output is correct
32 Correct 119 ms 4912 KB Output is correct
33 Correct 248 ms 4988 KB Output is correct
34 Correct 125 ms 5060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 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 1 ms 204 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 101 ms 4896 KB Output is correct
12 Correct 112 ms 4936 KB Output is correct
13 Correct 85 ms 4988 KB Output is correct
14 Correct 84 ms 4956 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 52 ms 2660 KB Output is correct
24 Correct 33 ms 1868 KB Output is correct
25 Correct 25 ms 1420 KB Output is correct
26 Correct 20 ms 1268 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 296 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 2 ms 332 KB Output is correct
42 Correct 4 ms 460 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 24 ms 1100 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 2 ms 332 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 52 ms 2628 KB Output is correct
52 Correct 34 ms 1824 KB Output is correct
53 Correct 33 ms 1808 KB Output is correct
54 Correct 32 ms 1052 KB Output is correct
55 Correct 72 ms 2404 KB Output is correct
56 Correct 12 ms 716 KB Output is correct
57 Correct 89 ms 4996 KB Output is correct
58 Correct 102 ms 4992 KB Output is correct
59 Correct 112 ms 4876 KB Output is correct
60 Correct 130 ms 5064 KB Output is correct
61 Correct 205 ms 4992 KB Output is correct
62 Correct 119 ms 4912 KB Output is correct
63 Correct 248 ms 4988 KB Output is correct
64 Correct 125 ms 5060 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 31 ms 4932 KB Output is correct
67 Correct 102 ms 4968 KB Output is correct
68 Correct 91 ms 4992 KB Output is correct
69 Correct 23 ms 964 KB Output is correct
70 Correct 6 ms 448 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 36 ms 1236 KB Output is correct
73 Correct 8 ms 512 KB Output is correct
74 Correct 1 ms 344 KB Output is correct
75 Correct 110 ms 6976 KB Output is correct
76 Correct 116 ms 6752 KB Output is correct
77 Correct 129 ms 6232 KB Output is correct
78 Correct 174 ms 5272 KB Output is correct
79 Correct 225 ms 6728 KB Output is correct
80 Correct 258 ms 9628 KB Output is correct
81 Correct 216 ms 6512 KB Output is correct
82 Correct 208 ms 6796 KB Output is correct