Submission #936134

# Submission time Handle Problem Language Result Execution time Memory
936134 2024-03-01T08:17:56 Z weakweakweak Self Study (JOI22_ho_t2) C++14
0 / 100
502 ms 5212 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
ll n, m, a[310000], b[310000];

bool can (ll v) {
    ll now = 0;
    for (int i = 1; i <= n; i++) {
        ll inclass = (v + a[i] - 1) / a[i];
        if (inclass == m) continue;
        if (inclass < m) now += m - inclass;
        else {
            ll z = v - m * a[i];
            now -= (z + b[i] - 1) / b[i];
        }
    }
return now >= 0;}

int main () {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        cin >> b[i];
        a[i] = max(a[i], b[i]);
    }

    ll l = 0, r = 4e18;
    while (l + 20 < r) {
        ll mid = (l + r) / 2;
        if (can(mid)) l = mid;
        else r = mid;
    }
    while (can(l + 1) and l <= r) l++;
    // cout << can(19) << '\n';
    cout << l << '\n'; 
return 0;}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 223 ms 5212 KB Output is correct
12 Correct 216 ms 5212 KB Output is correct
13 Correct 221 ms 5212 KB Output is correct
14 Incorrect 502 ms 5208 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 114 ms 4700 KB Output is correct
10 Correct 77 ms 4696 KB Output is correct
11 Correct 60 ms 4736 KB Output is correct
12 Correct 47 ms 4952 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Incorrect 8 ms 2544 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 223 ms 5212 KB Output is correct
12 Correct 216 ms 5212 KB Output is correct
13 Correct 221 ms 5212 KB Output is correct
14 Incorrect 502 ms 5208 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 114 ms 4700 KB Output is correct
10 Correct 77 ms 4696 KB Output is correct
11 Correct 60 ms 4736 KB Output is correct
12 Correct 47 ms 4952 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Incorrect 8 ms 2544 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2648 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2508 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 223 ms 5212 KB Output is correct
12 Correct 216 ms 5212 KB Output is correct
13 Correct 221 ms 5212 KB Output is correct
14 Incorrect 502 ms 5208 KB Output isn't correct
15 Halted 0 ms 0 KB -