Submission #693305

# Submission time Handle Problem Language Result Execution time Memory
693305 2023-02-02T16:05:49 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,vector<int> X,long long B){
    long long r =0 ;
    long long 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/ccb8RtSc.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