Submission #879932

# Submission time Handle Problem Language Result Execution time Memory
879932 2023-11-28T11:05:55 Z frostray8653 Self Study (JOI22_ho_t2) C++17
0 / 100
425 ms 10948 KB
#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
using pii = pair<int, int>;
const int N = 300005;
const int INF = 1e18;
int n, m;
int a[N], b[N];

bool check(int k) {
    int cst_day = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] >= b[i]) {
            int need = (k + a[i] - 1) / a[i];
            if (need > m) {
                int less = k - m * a[i];
                cst_day += (less + b[i] - 1) / b[i];
            } else {
                cst_day -= m - need;
            }
        } else {
            int need = (k + b[i] - 1) / b[i];
            if (need > m)
                cst_day += need - m;
            else
                cst_day -= m - need;
        }
    }
    return (cst_day <= 0);
}

signed main() {
    IO;
    cin >> n >> m;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n) cin >> b[i];

    int l = 0, r = INF;
    while (l + 1 < r) {
        int mid = (l + r) >> 1;
        if (check(mid))
            l = mid;
        else
            r = mid;
    }
    cout << l << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 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 1 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 187 ms 10836 KB Output is correct
12 Correct 183 ms 10948 KB Output is correct
13 Correct 138 ms 8960 KB Output is correct
14 Incorrect 425 ms 8952 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 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 0 ms 2396 KB Output is correct
9 Correct 104 ms 7504 KB Output is correct
10 Correct 70 ms 6660 KB Output is correct
11 Correct 51 ms 6180 KB Output is correct
12 Correct 42 ms 5724 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 0 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 1 ms 2396 KB Output is correct
18 Incorrect 8 ms 2396 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 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 1 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 187 ms 10836 KB Output is correct
12 Correct 183 ms 10948 KB Output is correct
13 Correct 138 ms 8960 KB Output is correct
14 Incorrect 425 ms 8952 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 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 0 ms 2396 KB Output is correct
9 Correct 104 ms 7504 KB Output is correct
10 Correct 70 ms 6660 KB Output is correct
11 Correct 51 ms 6180 KB Output is correct
12 Correct 42 ms 5724 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 0 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 1 ms 2396 KB Output is correct
18 Incorrect 8 ms 2396 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 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 1 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 187 ms 10836 KB Output is correct
12 Correct 183 ms 10948 KB Output is correct
13 Correct 138 ms 8960 KB Output is correct
14 Incorrect 425 ms 8952 KB Output isn't correct
15 Halted 0 ms 0 KB -