Submission #1217384

#TimeUsernameProblemLanguageResultExecution timeMemory
1217384countlessRice Hub (IOI11_ricehub)C++20
42 / 100
1095 ms552 KiB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define sp <<" "<<
#define endl "\n"

int besthub(int R, int L, int X[], ll B) {
    int best = 0;

    auto process = [&](int x) -> int {
        int res = 0;
        ll have = B;
        priority_queue<ll, vector<ll>, greater<ll>> st;
        for (int i = 0; i < R; i++) {
            st.push(abs(X[i] - x));
        }

        while (!st.empty()) {
            int take = st.top(); st.pop();
            if (take > have) break;

            res++;
            have -= take;
        }

        return res;
    };

    // try placing
    for (int i = 0; i < R; i++) {
        best = max(best, process(X[i]));
    }

    return best;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...