Submission #1236274

#TimeUsernameProblemLanguageResultExecution timeMemory
1236274mathias_abadieRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>


using namespace std;

int besthub(int R, int L, const vector<int>& X, long long B) {
    int maxRice = 0;
    for (int hub = 1; hub <= L; ++hub) {
        vector<long long> costs;
        for (int i = 0; i < R; ++i) {
            costs.push_back(abs((long long)X[i] - hub));
        }
        sort(costs.begin(), costs.end());
        long long totalCost = 0;
        int count = 0;
        for (int i = 0; i < R; ++i) {
            totalCost += costs[i];
            if (totalCost <= B) {
                count++;
            } else {
                break;
            }
        }

        maxRice = max(maxRice, count);
    }

    return maxRice;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccLRZG2c.o: in function `main':
grader.cpp:(.text.startup+0xaa): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status