Submission #1028953

# Submission time Handle Problem Language Result Execution time Memory
1028953 2024-07-20T10:43:31 Z tvladm2009 Self Study (JOI22_ho_t2) C++17
100 / 100
203 ms 11536 KB
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n + 1), b(n + 1);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) cin >> b[i];
    for (int i = 1; i <= n; ++i) a[i] = max(a[i], b[i]);
 
    __int128 l = 1, r = 1e18 * 1e9, sol = 0;
    while (l <= r) {
        __int128 mid = (l + r) / 2;
        __int128 days = 0;
        __int128 need = 0;
        for (int i = 1; i <= n; ++i) {
            if ((__int128) a[i] * m >= mid) {
                days += (__int128) m - (mid + a[i] - 1) / a[i];
            } else {
                need += (__int128) (mid - (__int128) a[i] * m + b[i] - 1) / (__int128) b[i];
            }
        }
        if (need <= days) {
            sol = mid;
            l = mid + 1;
        } else {
            r = mid - 1;
        }
    }
    if (sol == 0) {
        cout << 0;
        return 0;
    }
    vector<int> d;
    while (sol > 0) {
        d.push_back(sol % 10);
        sol /= 10;
    }
    reverse(d.begin(), d.end());
    for (auto i : d) cout << i;
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 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 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 176 ms 10936 KB Output is correct
12 Correct 151 ms 10836 KB Output is correct
13 Correct 127 ms 8708 KB Output is correct
14 Correct 167 ms 8948 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 133 ms 6320 KB Output is correct
17 Correct 158 ms 11536 KB Output is correct
18 Correct 143 ms 10884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 133 ms 6320 KB Output is correct
3 Correct 158 ms 11536 KB Output is correct
4 Correct 143 ms 10884 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 456 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 68 ms 5464 KB Output is correct
14 Correct 57 ms 3928 KB Output is correct
15 Correct 33 ms 2912 KB Output is correct
16 Correct 30 ms 2396 KB Output is correct
17 Correct 1 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 460 KB Output is correct
22 Correct 2 ms 548 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 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 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 176 ms 10936 KB Output is correct
12 Correct 151 ms 10836 KB Output is correct
13 Correct 127 ms 8708 KB Output is correct
14 Correct 167 ms 8948 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 456 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 68 ms 5464 KB Output is correct
24 Correct 57 ms 3928 KB Output is correct
25 Correct 33 ms 2912 KB Output is correct
26 Correct 30 ms 2396 KB Output is correct
27 Correct 1 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 460 KB Output is correct
32 Correct 2 ms 548 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 133 ms 6320 KB Output is correct
36 Correct 158 ms 11536 KB Output is correct
37 Correct 143 ms 10884 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 456 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 460 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 4 ms 636 KB Output is correct
46 Correct 8 ms 604 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 33 ms 2244 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 452 KB Output is correct
55 Correct 78 ms 5656 KB Output is correct
56 Correct 54 ms 3288 KB Output is correct
57 Correct 52 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 68 ms 5464 KB Output is correct
10 Correct 57 ms 3928 KB Output is correct
11 Correct 33 ms 2912 KB Output is correct
12 Correct 30 ms 2396 KB Output is correct
13 Correct 1 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 460 KB Output is correct
18 Correct 2 ms 548 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 133 ms 6320 KB Output is correct
22 Correct 158 ms 11536 KB Output is correct
23 Correct 143 ms 10884 KB Output is correct
24 Correct 27 ms 2076 KB Output is correct
25 Correct 72 ms 5156 KB Output is correct
26 Correct 21 ms 1332 KB Output is correct
27 Correct 146 ms 10780 KB Output is correct
28 Correct 180 ms 10908 KB Output is correct
29 Correct 174 ms 10956 KB Output is correct
30 Correct 203 ms 10904 KB Output is correct
31 Correct 175 ms 10896 KB Output is correct
32 Correct 125 ms 6236 KB Output is correct
33 Correct 180 ms 11504 KB Output is correct
34 Correct 131 ms 6236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 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 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 176 ms 10936 KB Output is correct
12 Correct 151 ms 10836 KB Output is correct
13 Correct 127 ms 8708 KB Output is correct
14 Correct 167 ms 8948 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 456 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 68 ms 5464 KB Output is correct
24 Correct 57 ms 3928 KB Output is correct
25 Correct 33 ms 2912 KB Output is correct
26 Correct 30 ms 2396 KB Output is correct
27 Correct 1 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 460 KB Output is correct
32 Correct 2 ms 548 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 456 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 460 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 4 ms 636 KB Output is correct
42 Correct 8 ms 604 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 33 ms 2244 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 452 KB Output is correct
51 Correct 78 ms 5656 KB Output is correct
52 Correct 54 ms 3288 KB Output is correct
53 Correct 52 ms 3164 KB Output is correct
54 Correct 27 ms 2076 KB Output is correct
55 Correct 72 ms 5156 KB Output is correct
56 Correct 21 ms 1332 KB Output is correct
57 Correct 146 ms 10780 KB Output is correct
58 Correct 180 ms 10908 KB Output is correct
59 Correct 174 ms 10956 KB Output is correct
60 Correct 203 ms 10904 KB Output is correct
61 Correct 175 ms 10896 KB Output is correct
62 Correct 125 ms 6236 KB Output is correct
63 Correct 180 ms 11504 KB Output is correct
64 Correct 131 ms 6236 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 133 ms 6320 KB Output is correct
67 Correct 158 ms 11536 KB Output is correct
68 Correct 143 ms 10884 KB Output is correct
69 Correct 30 ms 1604 KB Output is correct
70 Correct 6 ms 736 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 24 ms 1988 KB Output is correct
73 Correct 6 ms 604 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 175 ms 10948 KB Output is correct
76 Correct 151 ms 10952 KB Output is correct
77 Correct 180 ms 10952 KB Output is correct
78 Correct 174 ms 10900 KB Output is correct
79 Correct 174 ms 10904 KB Output is correct
80 Correct 159 ms 10956 KB Output is correct
81 Correct 177 ms 8968 KB Output is correct
82 Correct 158 ms 8848 KB Output is correct