Submission #693302

# Submission time Handle Problem Language Result Execution time Memory
693302 2023-02-02T16:03:58 Z Ahmed57 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 R,int L,int X[],int B){
    long long r =0 ;
    int pref[R];
    pref[0] = X[0];
    for(int i = 1;i<R;i++){
        pref[i] = X[i]+pref[i-1];
    }
    long long ans = 0;
    for(int l= 0;l<R;l++){
        while(r<R){
            int mid=(l+r)/2;
            long long e1 = pref[mid];
            if(l!=0)e1-=pref[l-1];
            e1 = (X[mid]*(mid-l+1))-e1;
            long long e2 = pref[r]-pref[mid];
            e2 = e2-(X[mid]*(r-mid));
            if(e1+e2<=B){
                r++;
            }else break;
        }
        ans = max(ans,r-l);
    }
    return ans;
}
/*int main(){
    vector<int>v = {1,2,10,12,14};
    cout<<besthub(5,20,v,6);
}*/

Compilation message

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