Submission #581250

# Submission time Handle Problem Language Result Execution time Memory
581250 2022-06-22T12:29:18 Z stevancv Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 3e4 + 2;
ll besthub(int N, int M, int K, int A[]) {
    ll n = N; ll k = K;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        a[i] = A[i];
        if (i > 0) a[i] += a[i - 1];
    }
    auto Get = [&] (ll l, ll r) {
        if (l > r) return 0LL;
        ll ans = a[r];
        if (l > 0) ans -= a[l - 1];
        return ans;
    };
    auto Can = [&] (ll x) {
        for (ll i = 0; i <= n - x; i++) {
            ll j = i + x - 1;
            ll o = i + j >> 1;
            ll val = Get(o, o);
            ll tr = val * (o - i + 1) - Get(i, o);
            tr += Get(o + 1, j) - val * (j - o);
            if (tr <= k) return true;
        }
        return false;
    };
    ll l = 1; ll r = n;
    ll ans = l;
    while (l <= r) {
        ll mid = l + r >> 1;
        if (Can(mid)) {
            l = mid + 1;
            ans = mid;
        }
        else r = mid - 1;
    }
    return ans;
}

Compilation message

ricehub.cpp: In lambda function:
ricehub.cpp:27:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |             ll o = i + j >> 1;
      |                    ~~^~~
ricehub.cpp: In function 'long long int besthub(int, int, int, int*)':
ricehub.cpp:38:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   38 |         ll mid = l + r >> 1;
      |                  ~~^~~
/usr/bin/ld: /tmp/ccLFyod8.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