Submission #895854

# Submission time Handle Problem Language Result Execution time Memory
895854 2023-12-30T22:39:31 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
0 / 100
4 ms 860 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define f first
#define s second

int n;
ll budget;
vector<ll> psum;
vector<ll> ssum;

bool check(int rice) {
    ll middle = (rice-1) / 2;
    ll right = middle+(rice)/2;
    ll minb = 1e9;
    for (int i = 0; i <= n - rice; i++) {
        ll b = psum[i+right] - psum[i+middle] + ssum[i] - ssum[i+middle];
        minb = min(b, minb);
    }
    //cout << "minb: " << minb << endl;
    if (minb <= budget) return true;
    return false;
}


int besthub(int ri, int maxcoor, int a[], ll b) {
    n = ri;
    budget = b;
    ll diff[n-1];
    for (int i = 0; i < n-1; i++) {
        diff[i] = (ll)(a[i+1] - a[i]);
    }
    psum.resize(n);
    ssum.resize(n);

    for (int i = 1; i < n; i++) {
        psum[i] = diff[i-1] + psum[i-1];
    }
    for (int i = n-2; i >= 0; i--) {
        ssum[i] = diff[i] + ssum[i+1];
    }

    ll l = 1, r = (ll)n;
    while (l < r) {
        ll mid = (l + r + 1) / 2;
        //cout << "mid: " << mid << endl;
        if (check(mid)) {
            l = mid;
        }
        else {
            r = mid - 1;
        }
    }
    return l;
}

// signed main() {
//     int r, l, b; cin >> r >> l >> b;
//     int x[r];
//     for (int i = 0; i < r; i++) cin >> x[i];
//     cout << besthub(r, l, x, b) << endl;
// }
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -