Submission #843872

# Submission time Handle Problem Language Result Execution time Memory
843872 2023-09-04T16:18:20 Z ZeroCool Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define ll long long

#define int long long

const int N = 100005;

using namespace std;

int pref[N];

int sum(int a,int b){
    return pref[b] - pref[a-1];
}

int32_t besthub(int n, int l, int X[], int k){
    int A[n+1];

    for(int i = 1;i<=n;i++){
        A[i] = X[i-1];
        pref[i] = pref[i-1] + A[i];
    }
    int res = 0;
    for(int i = 1;i<=n;i++){
        int lo = i;
        int hi = n;

        while(lo <= hi){
            int mid = (lo + hi)/2;
            int x = (i + mid) /2 ;
            int val = (A[x]*(x-i) - sum(i,x-1)) + (sum(x+1, mid) - A[x] * (mid-x));

            if(val <= k){
                res = max(res, mid - i + 1);
                lo = mid + 1;
            }else{
                hi = mid - 1;
            }
        }
    }

    return res;
}

Compilation message

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