Submission #1241864

#TimeUsernameProblemLanguageResultExecution timeMemory
1241864mrivera11Message (IOI24_message)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int r;
ll l, b;
vector<ll> x, pr;

bool cn(int k) {
    for (int i = 0; i + k <= r; ++i) {
        int j = i + k - 1;
        int m = (i + j) / 2;
        ll L = x[m] * (m - i) - (pr[m - 1] - (i > 0 ? pr[i - 1] : 0));
        ll R = (pr[j] - pr[m]) - x[m] * (j - m);
        if (L + R <= b) return true;
    }
    return false;
}

int bh(int r_, int l_, vector<int>& x_, ll b_) {
    r = r_; l = l_; b = b_;
    x = vector<ll>(x_.begin(), x_.end());
    pr.resize(r);
    pr[0] = x[0];
    for (int i = 1; i < r; ++i) pr[i] = pr[i - 1] + x[i];

    int lo = 1, hi = r, ans = 1;
    while (lo <= hi) {
        int k = (lo + hi) / 2;
        if (cn(k)) ans = k, lo = k + 1;
        else hi = k - 1;
    }
    return ans;
}

int main() {
    int r = 5; ll l = 20, b = 6;
    vector<int> x = {1, 2, 10, 12, 14};
    cout << bh(r, l, x, b) << endl; 
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccFXodb4.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccaLXHiN.o:message.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccFXodb4.o: in function `(anonymous namespace)::run_decoder()':
stub.cpp:(.text+0x6a1): undefined reference to `receive_message(std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >)'
/usr/bin/ld: /tmp/ccFXodb4.o: in function `(anonymous namespace)::run_encoder()':
stub.cpp:(.text+0xc33): undefined reference to `send_message(std::vector<bool, std::allocator<bool> >, std::vector<bool, std::allocator<bool> >)'
collect2: error: ld returned 1 exit status