Submission #783324

# Submission time Handle Problem Language Result Execution time Memory
783324 2023-07-14T20:45:01 Z thimote75 Self Study (JOI22_ho_t2) C++14
0 / 100
356 ms 4984 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

using idata = vector<int>;

int N, M;

idata As, Bs;

int ceilDiv (int x, int y) {
    return (x + y - 1) / y;
}

int solve (int A, int B, int target) {
    if (A < B) A = B;

    if (A * M >= target)
        return M - ceilDiv(target, A);
    
    int local = target - A * M;

    return - ceilDiv(local, B);
}

bool check (int target) {
    int res = 0;
    for (int i = 0; i < N; i ++) 
        res += solve(As[i], Bs[i], target);
    
    return res >= 0;
}

signed main () {
    cin >> N >> M;

    As.resize(N); Bs.resize(N);
    for (int i = 0; i < N; i ++) cin >> As[i];
    for (int i = 0; i < N; i ++) cin >> Bs[i];

    int a = 0;
    int b = 2e18;
    while (b - a > 1) {
        int c = (a + b) >> 1;

        if (check(c)) a = c;
        else b = c;
    }

    cout << a << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 258 ms 4984 KB Output is correct
12 Correct 258 ms 4980 KB Output is correct
13 Correct 244 ms 4984 KB Output is correct
14 Incorrect 356 ms 4984 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 133 ms 2644 KB Output is correct
10 Correct 87 ms 1856 KB Output is correct
11 Correct 65 ms 1364 KB Output is correct
12 Correct 52 ms 1236 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 6 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 258 ms 4984 KB Output is correct
12 Correct 258 ms 4980 KB Output is correct
13 Correct 244 ms 4984 KB Output is correct
14 Incorrect 356 ms 4984 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 133 ms 2644 KB Output is correct
10 Correct 87 ms 1856 KB Output is correct
11 Correct 65 ms 1364 KB Output is correct
12 Correct 52 ms 1236 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 6 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 258 ms 4984 KB Output is correct
12 Correct 258 ms 4980 KB Output is correct
13 Correct 244 ms 4984 KB Output is correct
14 Incorrect 356 ms 4984 KB Output isn't correct
15 Halted 0 ms 0 KB -