Submission #1301152

#TimeUsernameProblemLanguageResultExecution timeMemory
1301152pashtetkasRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
// Header Files and namespaces
#include <bits/stdc++.h>

using namespace std;

// Code shorteners
typedef long long ll;
#define print(x) cout << x << '\n' 
#define endl '\n'                  
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

bool check(int k, vector<ll>&pref, int R, ll B){
    ll min_wyn = LLONG_MAX;
    int n = R - k + 1;
    for(int l = 1; l<=n; l++){
        int r = l + k - 1;
        int m = l + (k/2);
        ll temp_wyn = (m - l)*pref[m] - (pref[m] - pref[l-1]);
        temp_wyn += (pref[r] - pref[m]) - (r - (m+1) + 1)*pref[m];
        min_wyn = min(min_wyn, temp_wyn);
    }
    if(min_wyn <= B)return true;
    else return false;
}

ll besthub(int R, ll L, vector<int>&X, ll B){
    if(B == 0)return 0;
    vector<ll>pref(R+7, 0);
    for(int i = 1; i<=R; i++)pref[i] = pref[i-1] + X[i-1];
    int l = 1;
    int r = R;
    int wyn = 0;
    while(l<=r){
        int mid = (l+r)/2;
        if(check(mid, pref, R, B)){
            l = mid + 1;
            wyn = max(wyn, mid);
        }
        else r = mid - 1;
    }
    return wyn;
}

// Code
int main() {  
    fast;
    /*int R;
    ll L, B;
    vector<int>X(R);
    cin >> R >> L >> B;
    for(int i = 0; i<R; i++)cin>>X[i];
    cout << besthub(R, L, X, B) << '\n';*/
    
    
    return 0;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccTHsdqS.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctDSzzh.o:ricehub.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccTHsdqS.o: in function `main':
grader.cpp:(.text.startup+0xaa): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status