Submission #595497

# Submission time Handle Problem Language Result Execution time Memory
595497 2022-07-13T19:14:15 Z someone Self Study (JOI22_ho_t2) C++14
0 / 100
354 ms 5000 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 3e5 + 42, INF = 1e18 + 42;

int n, m, a[N], b[N];

bool possible(int mini) {
    int need = 0;
    for(int i = 0; i < n; i++)
        if(m * a[i] < mini)
            need += (mini - m * a[i] + b[i] - 1) / b[i];
        else
            need -= m - (mini + a[i] - 1) / a[i];
    return need <= 0;
}

int dicho(int deb, int fin) {
    if(deb + 1 == fin)
        return deb;

    int mid = (deb + fin) >> 1;
    if(possible(mid))
        return dicho(mid, fin);
    return dicho(deb, mid);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> m;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++)
        cin >> b[i];
    for(int i = 0; i < n; i++)
        a[i] = max(a[i], b[i]);

    cout << dicho(0, INF);
}
# 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 178 ms 5000 KB Output is correct
12 Correct 193 ms 4916 KB Output is correct
13 Correct 175 ms 5000 KB Output is correct
14 Incorrect 354 ms 4996 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 87 ms 2660 KB Output is correct
10 Correct 61 ms 1772 KB Output is correct
11 Correct 43 ms 1496 KB Output is correct
12 Correct 42 ms 1236 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
18 Incorrect 5 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 178 ms 5000 KB Output is correct
12 Correct 193 ms 4916 KB Output is correct
13 Correct 175 ms 5000 KB Output is correct
14 Incorrect 354 ms 4996 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 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 87 ms 2660 KB Output is correct
10 Correct 61 ms 1772 KB Output is correct
11 Correct 43 ms 1496 KB Output is correct
12 Correct 42 ms 1236 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
18 Incorrect 5 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 178 ms 5000 KB Output is correct
12 Correct 193 ms 4916 KB Output is correct
13 Correct 175 ms 5000 KB Output is correct
14 Incorrect 354 ms 4996 KB Output isn't correct
15 Halted 0 ms 0 KB -