Submission #485234

# Submission time Handle Problem Language Result Execution time Memory
485234 2021-11-06T15:39:38 Z chungdinh Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include <cstdio>
#include <string>
#include <queue>
#include <iostream>

using namespace std;

#define endl "\n"
#define cntbit(x) __builtin_popcount(x)
#define on(b, x) (b & (1 << x))
#define all(x) x.begin(), x.end()
#define gcd __gcd
#define ll long long
#define ii pair<int, int>

#define cost(l, r) a[r] - a[l]

const int N = 3e3 + 5;
const ll MOD = 998244353;
const int iINF = 1e9;
const ll INF = 1e18;

int n;
ll l, b;
ll a[N];

int besthub(int n, ll l, ll a[N], ll  b) {
    int res = 0;

    for (int i = 0; i < n; i++) {
        int l = i - 1, r = i + 1;

        int subres = 0;
        ll left = b;

        while (l >= 0 || r <= n - 1) {
            if (l < 0) {
                if (cost(i, r) > left) break;
                subres++;
                left -= cost(i, r);
                r++;
            } else if (r > n - 1) {
                if (cost(l, i) > left) break;
                subres++;
                left -= cost(l, i);
                l--;
            } else {
                ll tt = min(cost(l, i), cost(i, r));
                if (tt > left) break;

                if (cost(l, i) < cost(i, r)) {
                    left -= cost(l, i);
                    l--;
                } else {
                    left -= cost(i, r);
                    r++;
                }
                subres++;
            }
        }

        res = max(res, subres + 1);
    }

    return res;
}
/*
int main() {
    #ifdef CHUNGDINH
    freopen("main.inp", "r", stdin);
    #endif

    scanf("%d%lld%lld",&n,&l,&b);
    for (int i = 0; i < n; i++) scanf("%lld", a + i);

    printf("%d", besthub(n, l, a, b));
}*/

Compilation message

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