Submission #1030866

# Submission time Handle Problem Language Result Execution time Memory
1030866 2024-07-22T10:59:48 Z VMaksimoski008 Self Study (JOI22_ho_t2) C++17
64 / 100
226 ms 11512 KB
#include <bits/stdc++.h>

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;

signed 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];

    if(m == 1) {
        ll ans = 1e18;
        for(int i=1; i<=n; i++) ans = min(ans, max(a[i], b[i]));
        cout << ans << '\n';
        return 0;
    }

    __int128_t l=1, r=1e18, ans=0;
    while(l <= r) {
        __int128_t mid = (l + r) / 2;
        __int128_t total = 0;

        for(__int128_t i=1; i<=n; i++) total += (mid + a[i] - 1) / a[i];

        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 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 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 2 ms 348 KB Output is correct
11 Correct 139 ms 10736 KB Output is correct
12 Correct 137 ms 10836 KB Output is correct
13 Correct 101 ms 8684 KB Output is correct
14 Correct 105 ms 8784 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 55 ms 6268 KB Output is correct
17 Correct 149 ms 11344 KB Output is correct
18 Correct 141 ms 10880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 55 ms 6268 KB Output is correct
3 Correct 149 ms 11344 KB Output is correct
4 Correct 141 ms 10880 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 436 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 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 116 ms 5460 KB Output is correct
14 Correct 71 ms 3924 KB Output is correct
15 Correct 57 ms 2896 KB Output is correct
16 Correct 43 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 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 4 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 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 2 ms 348 KB Output is correct
11 Correct 139 ms 10736 KB Output is correct
12 Correct 137 ms 10836 KB Output is correct
13 Correct 101 ms 8684 KB Output is correct
14 Correct 105 ms 8784 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 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 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 116 ms 5460 KB Output is correct
24 Correct 71 ms 3924 KB Output is correct
25 Correct 57 ms 2896 KB Output is correct
26 Correct 43 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 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 4 ms 604 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 55 ms 6268 KB Output is correct
36 Correct 149 ms 11344 KB Output is correct
37 Correct 141 ms 10880 KB Output is correct
38 Incorrect 0 ms 344 KB Output isn't correct
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 436 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 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 116 ms 5460 KB Output is correct
10 Correct 71 ms 3924 KB Output is correct
11 Correct 57 ms 2896 KB Output is correct
12 Correct 43 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 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 4 ms 604 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 55 ms 6268 KB Output is correct
22 Correct 149 ms 11344 KB Output is correct
23 Correct 141 ms 10880 KB Output is correct
24 Correct 34 ms 1884 KB Output is correct
25 Correct 94 ms 5128 KB Output is correct
26 Correct 23 ms 1372 KB Output is correct
27 Correct 215 ms 10884 KB Output is correct
28 Correct 215 ms 10836 KB Output is correct
29 Correct 212 ms 10836 KB Output is correct
30 Correct 206 ms 10864 KB Output is correct
31 Correct 219 ms 10836 KB Output is correct
32 Correct 124 ms 6228 KB Output is correct
33 Correct 226 ms 11512 KB Output is correct
34 Correct 126 ms 6224 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 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 2 ms 348 KB Output is correct
11 Correct 139 ms 10736 KB Output is correct
12 Correct 137 ms 10836 KB Output is correct
13 Correct 101 ms 8684 KB Output is correct
14 Correct 105 ms 8784 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 436 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 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 116 ms 5460 KB Output is correct
24 Correct 71 ms 3924 KB Output is correct
25 Correct 57 ms 2896 KB Output is correct
26 Correct 43 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 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 4 ms 604 KB Output is correct
34 Incorrect 0 ms 344 KB Output isn't correct
35 Halted 0 ms 0 KB -