Submission #936309

# Submission time Handle Problem Language Result Execution time Memory
936309 2024-03-01T14:47:55 Z qwe1rt1yuiop1 Self Study (JOI22_ho_t2) C++14
100 / 100
224 ms 11348 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    for (int &i : a)
        cin >> i;
    for (int &i : b)
        cin >> i;

    int l = 0, r = 3e18;
    while (l + 1 < r)
    {
        int mid = (l + r) >> 1, lft = n * m;

        for (int i = 0; i < n && lft >= 0; ++i)
            if (a[i] <= b[i])
            {
                int cnt = mid / b[i] + (mid % b[i] > 0);
                assert(cnt * b[i] >= mid && (cnt - 1) * b[i] < mid);
                lft -= cnt;
            }
            else
            {
                int cnt = mid / a[i] + (mid % a[i] > 0);
                cnt = min(cnt, m);
                lft -= cnt;
                if (lft < 0)
                    break;
                if (cnt * a[i] < mid)
                {
                    cnt = (mid - cnt * a[i]) / b[i] + ((mid - cnt * a[i]) % b[i] > 0);
                    lft -= cnt;
                }
            }

        if (lft >= 0)
            l = mid;
        else
            r = mid;
    }
    cout << l << '\n';
}

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

    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 92 ms 10900 KB Output is correct
12 Correct 92 ms 10900 KB Output is correct
13 Correct 71 ms 8712 KB Output is correct
14 Correct 64 ms 8784 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 27 ms 6148 KB Output is correct
17 Correct 82 ms 11348 KB Output is correct
18 Correct 88 ms 10832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 27 ms 6148 KB Output is correct
3 Correct 82 ms 11348 KB Output is correct
4 Correct 88 ms 10832 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 460 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 43 ms 5616 KB Output is correct
14 Correct 29 ms 3924 KB Output is correct
15 Correct 22 ms 2908 KB Output is correct
16 Correct 18 ms 2396 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 92 ms 10900 KB Output is correct
12 Correct 92 ms 10900 KB Output is correct
13 Correct 71 ms 8712 KB Output is correct
14 Correct 64 ms 8784 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 460 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 43 ms 5616 KB Output is correct
24 Correct 29 ms 3924 KB Output is correct
25 Correct 22 ms 2908 KB Output is correct
26 Correct 18 ms 2396 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 464 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 27 ms 6148 KB Output is correct
36 Correct 82 ms 11348 KB Output is correct
37 Correct 88 ms 10832 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 600 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 4 ms 956 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 19 ms 2160 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 604 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 0 ms 344 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 49 ms 5576 KB Output is correct
56 Correct 27 ms 3160 KB Output is correct
57 Correct 21 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 460 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 43 ms 5616 KB Output is correct
10 Correct 29 ms 3924 KB Output is correct
11 Correct 22 ms 2908 KB Output is correct
12 Correct 18 ms 2396 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 464 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 27 ms 6148 KB Output is correct
22 Correct 82 ms 11348 KB Output is correct
23 Correct 88 ms 10832 KB Output is correct
24 Correct 26 ms 2348 KB Output is correct
25 Correct 63 ms 4956 KB Output is correct
26 Correct 12 ms 1328 KB Output is correct
27 Correct 84 ms 10756 KB Output is correct
28 Correct 98 ms 10904 KB Output is correct
29 Correct 90 ms 10936 KB Output is correct
30 Correct 110 ms 11156 KB Output is correct
31 Correct 187 ms 10884 KB Output is correct
32 Correct 108 ms 6232 KB Output is correct
33 Correct 213 ms 11344 KB Output is correct
34 Correct 107 ms 6312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 92 ms 10900 KB Output is correct
12 Correct 92 ms 10900 KB Output is correct
13 Correct 71 ms 8712 KB Output is correct
14 Correct 64 ms 8784 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 460 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 43 ms 5616 KB Output is correct
24 Correct 29 ms 3924 KB Output is correct
25 Correct 22 ms 2908 KB Output is correct
26 Correct 18 ms 2396 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 464 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 600 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 4 ms 956 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 19 ms 2160 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 604 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 49 ms 5576 KB Output is correct
52 Correct 27 ms 3160 KB Output is correct
53 Correct 21 ms 3164 KB Output is correct
54 Correct 26 ms 2348 KB Output is correct
55 Correct 63 ms 4956 KB Output is correct
56 Correct 12 ms 1328 KB Output is correct
57 Correct 84 ms 10756 KB Output is correct
58 Correct 98 ms 10904 KB Output is correct
59 Correct 90 ms 10936 KB Output is correct
60 Correct 110 ms 11156 KB Output is correct
61 Correct 187 ms 10884 KB Output is correct
62 Correct 108 ms 6232 KB Output is correct
63 Correct 213 ms 11344 KB Output is correct
64 Correct 107 ms 6312 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 27 ms 6148 KB Output is correct
67 Correct 82 ms 11348 KB Output is correct
68 Correct 88 ms 10832 KB Output is correct
69 Correct 21 ms 1612 KB Output is correct
70 Correct 6 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 31 ms 1980 KB Output is correct
73 Correct 6 ms 604 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 103 ms 10936 KB Output is correct
76 Correct 115 ms 10940 KB Output is correct
77 Correct 124 ms 10932 KB Output is correct
78 Correct 153 ms 10936 KB Output is correct
79 Correct 208 ms 10936 KB Output is correct
80 Correct 224 ms 10936 KB Output is correct
81 Correct 201 ms 8960 KB Output is correct
82 Correct 191 ms 8784 KB Output is correct