Submission #1030874

# Submission time Handle Problem Language Result Execution time Memory
1030874 2024-07-22T11:10:48 Z VMaksimoski008 Self Study (JOI22_ho_t2) C++17
0 / 100
232 ms 10864 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ll n, m;
    cin >> n >> m;

    vector<ll> 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_t l=1, r=1e18, ans=0;
    while(l <= r) {
        __int128_t mid = (l + r) / 2;
        ll total = 0;

        for(int i=1; i<=n; i++) {
            if(a[i] * m >= mid) total += (mid + a[i] - 1) / a[i];
            else total += (mid - a[i] * m + b[i] - 1) / b[i] + m;
        }

        if(total <= n * m) ans = mid, l = mid + 1;
        else r = mid - 1;
    }

    cout << (ll)ans << '\n';
    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 344 KB Output is correct
5 Correct 0 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 0 ms 348 KB Output is correct
10 Correct 4 ms 588 KB Output is correct
11 Correct 232 ms 10864 KB Output is correct
12 Correct 218 ms 10832 KB Output is correct
13 Correct 181 ms 8684 KB Output is correct
14 Incorrect 197 ms 8692 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
5 Correct 0 ms 448 KB Output is correct
6 Correct 0 ms 360 KB Output is correct
7 Correct 0 ms 360 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 115 ms 5464 KB Output is correct
10 Correct 78 ms 3936 KB Output is correct
11 Correct 63 ms 2900 KB Output is correct
12 Correct 46 ms 2528 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 348 KB Output is correct
18 Incorrect 2 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 344 KB Output is correct
5 Correct 0 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 0 ms 348 KB Output is correct
10 Correct 4 ms 588 KB Output is correct
11 Correct 232 ms 10864 KB Output is correct
12 Correct 218 ms 10832 KB Output is correct
13 Correct 181 ms 8684 KB Output is correct
14 Incorrect 197 ms 8692 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 360 KB Output is correct
5 Correct 0 ms 448 KB Output is correct
6 Correct 0 ms 360 KB Output is correct
7 Correct 0 ms 360 KB Output is correct
8 Correct 0 ms 360 KB Output is correct
9 Correct 115 ms 5464 KB Output is correct
10 Correct 78 ms 3936 KB Output is correct
11 Correct 63 ms 2900 KB Output is correct
12 Correct 46 ms 2528 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 348 KB Output is correct
18 Incorrect 2 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 344 KB Output is correct
5 Correct 0 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 0 ms 348 KB Output is correct
10 Correct 4 ms 588 KB Output is correct
11 Correct 232 ms 10864 KB Output is correct
12 Correct 218 ms 10832 KB Output is correct
13 Correct 181 ms 8684 KB Output is correct
14 Incorrect 197 ms 8692 KB Output isn't correct
15 Halted 0 ms 0 KB -