Submission #1138148

#TimeUsernameProblemLanguageResultExecution timeMemory
1138148MattNattFeczanRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

int besthub(int R, int L, vector<int>& X, long long B) {
    int max_fields = 0;

    // Iterate over all possible hub positions (1 to L)
    for (int hub = 1; hub <= L; ++hub) {
        // Calculate the cost of transporting rice for each subset of rice fields
        for (int start = 0; start < R; ++start) {
            long long cost = 0;
            int count = 0;

            for (int end = start; end < R; ++end) {
                cost += abs(X[end] - hub);
                if (cost > B) {
                    break;
                }

                count++;
                max_fields = max(max_fields, count);
            }
        }
    }

    return max_fields;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccW41YLq.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