Submission #889746

# Submission time Handle Problem Language Result Execution time Memory
889746 2023-12-20T06:46:30 Z arbuzick Self Study (JOI22_ho_t2) C++17
0 / 100
272 ms 8440 KB
#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    long long l = 0, r = 1e18 + 7;
    while (l < r - 1) {
        long long md = (l + r) / 2;
        long long free = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] <= b[i]) {
                free += m;
                free -= (md - 1) / b[i] + 1;
            } else if (a[i] * 1LL * m >= md) {
                long long vl = (md - 1) / a[i] + 1;
                free += m - vl;
            } else {
                free -= (md - a[i] * 1LL * m - 1) / b[i] + 1;
            }
        }
        if (free >= 0) {
            l = md;
        } else {
            r = md;
        }
    }
    cout << l << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 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 0 ms 452 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 148 ms 8396 KB Output is correct
12 Correct 149 ms 8440 KB Output is correct
13 Correct 132 ms 6480 KB Output is correct
14 Incorrect 272 ms 6484 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 348 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 72 ms 4528 KB Output is correct
10 Correct 48 ms 3416 KB Output is correct
11 Correct 36 ms 2396 KB Output is correct
12 Correct 30 ms 1948 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 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 Incorrect 4 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 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 0 ms 452 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 148 ms 8396 KB Output is correct
12 Correct 149 ms 8440 KB Output is correct
13 Correct 132 ms 6480 KB Output is correct
14 Incorrect 272 ms 6484 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 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 348 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 72 ms 4528 KB Output is correct
10 Correct 48 ms 3416 KB Output is correct
11 Correct 36 ms 2396 KB Output is correct
12 Correct 30 ms 1948 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 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 Incorrect 4 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 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 0 ms 452 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 148 ms 8396 KB Output is correct
12 Correct 149 ms 8440 KB Output is correct
13 Correct 132 ms 6480 KB Output is correct
14 Incorrect 272 ms 6484 KB Output isn't correct
15 Halted 0 ms 0 KB -