Submission #336073

# Submission time Handle Problem Language Result Execution time Memory
336073 2020-12-14T16:28:45 Z saarang123 Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

int besthub(int N, int L, int A[], int B) {
    int median;
    if(N % 2) median = A[N / 2];
    else median = (A[N / 2 - 1] + A[N / 2]) / 2;
    vector<int> distance;
    for(int i = 0; i < N; i++)
        distance.push_back(abs(A[i] - median));
    sort(distance.begin(), distance.end());
    int answer = 0;
    long long cost = 0;
    for(int i = 0; i < N; i++)
        if(cost + distance[i] <= B) {
            cost += distance[i];
            answer++;
        }
    return answer;
}

Compilation message

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