Submission #1327851

#TimeUsernameProblemLanguageResultExecution timeMemory
1327851arman.khachatryan쌀 창고 (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){
    long long pref[r+1];
    pref[0]=0;
    pref[1]=a[0];
    for(int i=2; i<=r; i++){
        pref[i]=pref[i-1]+a[i-1];
    }
    int j=0;
    long long cur, ans=1;
    for(int i=0; i<r; i++){
        while(j<=i){
            int mid=(i+j)/2;
            cur=(mid-j)*a[mid]-(pref[mid]-pref[j]);
            cur+=pref[i+1]-pref[mid+1]-(i-mid)*a[mid];
            if(cur>b){
                j++;
            }else{
                ans=max((i-j+1)*1LL, ans);
                break;
            }
        }
        
    }
    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/ccTn4M1M.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccdZV04V.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status