Submission #734403

# Submission time Handle Problem Language Result Execution time Memory
734403 2023-05-02T11:21:48 Z Josia Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
1 ms 324 KB
#include <bits/stdc++.h>

using namespace std;

#define int int64_t

int n, m;

bool check(int pos, vector<int>&a, vector<int>&b) {
    int free = 0;
    int req = 0;

    for (int i=0; i<n; i++) {
        int thisNeedsFromA = (pos+a[i]-1)/a[i];

        if (thisNeedsFromA <= m) {
            free += m-thisNeedsFromA;
        }
        else {
            req += (pos-a[i]*m + b[i]-1)/b[i];
        }
    }

    return free >= req;
}



signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin >> n >> m;

    vector<int> a(n), b(n);

    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]);



    int l = 0, r = 1e18;

    while (l < r) {
        int pos = (l + r + 1) / 2;

        if (check(pos, a, b)) {
            l = pos;
        } else {
            r = pos-1;
        }
    }


    cout << l << "\n";


    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 324 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -