Submission #1327723

#TimeUsernameProblemLanguageResultExecution timeMemory
1327723arman.khachatryanRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
long long besthub(int r, int l, int* a, long long b){
    int j, k, ans=0, cnt;
    long long c;
    bool bl;
    for(int i=0; i<r; i++){
        j=i-1;
        k=i+1;
        cnt=1;
        c=b;
        bl=true;
        while(c>0 && bl && (j>=0 || k<r)){
            if(0<=j && (k>=r || a[i]-a[j]<=a[k]-a[i])){
                if(c<a[i]-a[j]){
                    bl=false;
                    continue;
                }
                c-=(a[i]-a[j])*1LL;
                j--;
                cnt++;
            }
            if(k<r && (j<0 || a[i]-a[j]>=a[k]-a[i]) ){
                if(c<a[k]-a[i]){
                    bl=false;
                    continue;
                }
                c-=(a[k]-a[i])*1LL;
                k++;
                cnt++;
            }
        }
        ans=max(ans, cnt);
    }
    return ans;
}

int main(){
    int r, l;
    long long b;
    cin>>r>>l>>b;
    int a[r];
    for(int i=0; i<r; i++){
        cin>>a[i];
    }
    cout<<besthub(r, l, a, b);
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cc3gNqzy.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccp3syQM.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status