Submission #936135

# Submission time Handle Problem Language Result Execution time Memory
936135 2024-03-01T08:18:41 Z weakweakweak Self Study (JOI22_ho_t2) C++14
0 / 100
472 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 = 11e17;
    while (l + 10 < r) {
        ll mid = (l + r) / 2;
        if (can(mid)) l = mid;
        else r = mid;
    }
    while (can(l + 1)) l++;
    // cout << can(19) << '\n';
    cout << l << '\n'; 
return 0;}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 204 ms 4960 KB Output is correct
12 Correct 217 ms 5212 KB Output is correct
13 Correct 209 ms 5212 KB Output is correct
14 Incorrect 472 ms 5212 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 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 111 ms 4700 KB Output is correct
10 Correct 71 ms 4700 KB Output is correct
11 Correct 52 ms 4696 KB Output is correct
12 Correct 45 ms 4748 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Incorrect 9 ms 2548 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 204 ms 4960 KB Output is correct
12 Correct 217 ms 5212 KB Output is correct
13 Correct 209 ms 5212 KB Output is correct
14 Incorrect 472 ms 5212 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 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 111 ms 4700 KB Output is correct
10 Correct 71 ms 4700 KB Output is correct
11 Correct 52 ms 4696 KB Output is correct
12 Correct 45 ms 4748 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Incorrect 9 ms 2548 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2648 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 204 ms 4960 KB Output is correct
12 Correct 217 ms 5212 KB Output is correct
13 Correct 209 ms 5212 KB Output is correct
14 Incorrect 472 ms 5212 KB Output isn't correct
15 Halted 0 ms 0 KB -