Submission #809097

# Submission time Handle Problem Language Result Execution time Memory
809097 2023-08-05T17:12:14 Z annabeth9680 Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll> arr;
bool check(int val, int n, ll B){
    for(int i = 1;i<=n-val+1;++i){
        int r = i+val-1;
        int m = (i+r)/2;
        ll geld;
        if(val%2 == 0){
            geld = (arr[r]-arr[m])-(arr[m]-arr[i-1]);
        }
        else{
            geld = (arr[r]-arr[m])-(arr[m-1]-arr[i-1]);
        }
        if(geld <= B){
            //cout << val << " " << geld << " " << i << "\n";
            return true;
        }
    }
    return false;
}
int besthub(int R, int L, int X[], ll B){
    arr.resize(R+1); arr[0] = 0;
    for(int i = 1;i<=R;++i){
        arr[i] = arr[i-1]+X[i-1];
    }
    int l = 0, r = R;
    while(l < r){
        //cout << l << " " << r << "\n";
        int mid = (l+r+1)/2;
        if(check(mid,R,B)){
            l = mid;
        }
        else{
            r = mid-1;
        }
    }
    return l;
}
int main(){
    int X[6] = {1,2,10,12,14};
    cout << besthub(5,20,X,6) << "\n";
    return 0;
}

Compilation message

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