Submission #410781

#TimeUsernameProblemLanguageResultExecution timeMemory
410781LouayFarah쌀 창고 (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;


int besthub(long long R, long long L, long long X[], long long B)
{
    if(R==1)
        return 1;
    long long mediane = X[R/2];
    cout << mediane << endl;
    long long l =  R/2-1, r = R/2+1;
    long long res = 1;
    while((r<R||l>=0)&&(B>=0))
    {
        cout << l << ' ' << r << endl;
        if(l<0)
        {
            res++;
            B-=abs(mediane-X[r]);
            r++;
        }
        else if(r==R)
        {
            res++;
            B-=abs(mediane-X[l]);
            l--;
        }
        else if(abs(X[l]-mediane)<=abs(X[r]-mediane))
        {
            res++;
            B-=abs(mediane-X[l]);
            l--;
        }
        else if(abs(X[l]-mediane)>abs(X[r]-mediane))
        {
            res++;
            B-=abs(mediane-X[r]);
            r++;
        }
    }
    return res-1;
}

Compilation message (stderr)

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