Submission #715556

# Submission time Handle Problem Language Result Execution time Memory
715556 2023-03-27T08:09:55 Z vjudge1 Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

int besthub(int n,int l,int x[],int b){
    int cost,mid,ans=0;
    vector<int> prefixSum(l,0);

    for(int i=1;i<=n;i++)prefixSum[i] = prefixSum[i-1]+x[i-1];
    //for(int i=1;i<=n;i++)cout<<prefixSum[i]<<" "; cout<<endl;
    for(int st=1;st<=n;st++){
        for(int en=st;en<=n;en++){
            mid = (st+en)/2;
            cost = (mid-st)*x[mid]-(prefixSum[mid-1]-prefixSum[st-1]) + (prefixSum[en]-prefixSum[mid])-(en-mid)*x[mid];

            if(cost <= b)ans = max(ans,en-st+1);
            //cout<<st<<" "<<en<<" "<<cost<<endl;
        }
    }
    return ans;


}

Compilation message

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