Submission #895797

# Submission time Handle Problem Language Result Execution time Memory
895797 2023-12-30T21:01:11 Z vjudge1 Rice Hub (IOI11_ricehub) C++17
0 / 100
2 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int besthub(int N, int L, int X[], ll B) {
    vector<ll> prefix(N + 1);
    for (int i = 1; i <= N; i++) {
        prefix[i] = X[i - 1] + prefix[i - 1];
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int left = i;
        int right = N;
        while (left <= right) {
            int mid = (left + right) / 2;
            int median = (i + mid) / 2;
            ll total = (prefix[left + 1] - prefix[median]) - (left + 1 - median) * X[median - 1] +
                            (median - (i - 1)) * X[median - 1] - (prefix[median] - prefix[i - 1]);
            if (total <= B) {
                ans = max(ans, mid - i + 1);
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
    }
    return ans;
}

// int main() {
//     ios_base::sync_with_stdio(0);
//     cin.tie(0);
//     cout.tie(0);
//     int R, L;
//     cin >> R >> L;
//     int X[R];
//     for (ll i = 0; i < R; i++) {
//         cin >> X[i];
//     }
//     ll B;
//     cin >> B;
//     cout << besthub(R, L, X, B) << "\n";
// }
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 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 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -