Submission #884213

# Submission time Handle Problem Language Result Execution time Memory
884213 2023-12-06T18:39:45 Z TahirAliyev Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define int ll
#define pii pair<ll, ll>
#define oo 1e18
#define all(v) v.begin(), v.end()

const int MAX = 1e5 + 5;
int n, L, B;
int arr[MAX];
int pre[MAX];

signed besthub(int R, signed L, signed X[], long long B)
{
    cin >> n >> L >> B;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
        pre[i] = pre[i - 1] + arr[i];
    }
    int l = 1, r = n;
    int ans = 1;
    while(l <= r){
        int len = (l + r) / 2;
        int cost = 0;
        for(int s = 1; s <= n - len + 1; s++){
            int f = s + len - 1;
            int med = (s + f) / 2;
            cost = min(cost, (arr[med] * (med - s)) - (pre[med] - pre[s - 1]) 
                            + (arr[med] * (f - med)) - (pre[f] - pre[med]));
        }
        if(cost <= B){
            ans = len;
            l = len + 1;
        }
        else{
            r = len - 1;
        }
    }
    return ans;
}

Compilation message

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