Submission #537714

# Submission time Handle Problem Language Result Execution time Memory
537714 2022-03-15T11:58:59 Z timreizin Rice Hub (IOI11_ricehub) C++17
0 / 100
5 ms 596 KB
#include "ricehub.h"
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;

int besthub(int n, int l, int X[], ll b)
{
    vector<ll> x(n);
    for (int i = 0; i < n; ++i) x[i] = X[i];
    sort(x.begin(), x.end());
    vector<ll> pref(n);
    partial_sum(x.begin(), x.end(), pref.begin());
    int maxRes = 0;
    for (int i = 0; i < n; ++i)
    {
        int l = 0, r = n - i;
        while (l < r)
        {
            int m = (l + r) >> 1;
            int e = i + m;
            int v = (i + e) >> 1;
            ll sum = pref[e] - pref[v];
            if (v != 0) sum -= pref[v - 1] - (i == 0 ? 0ll : pref[i - 1]);
            if (i % 2 != m % 2) sum -= x[v];
            if (sum <= b) l = m + 1;
            else r = m;

        }
        maxRes = max(maxRes, l);
    }
    return maxRes;
}
# 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 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -