#include <bits/stdc++.h>
using namespace std;
int64_t find_shortcut(size_t n, vector<int> L, vector<int> D, int c)
{
vector<int64_t> X(n);
for(size_t i = 1; i < n; i++)
X[i] = X[i-1] + L[i-1];
int64_t lo = 0, hi = accumulate(L.begin(), L.end(), (int64_t)0) + accumulate(D.begin(), D.end(), (int64_t)0);
while(lo < hi)
{
int64_t k = (lo + hi) / 2;
int64_t u1 = INT64_MIN, u2 = INT64_MAX, v1 = INT64_MIN, v2 = INT64_MAX;
for(size_t i = 0; i < n; i++)
for(size_t j = 0; j < i; j++)
{
if(D[i] + D[j] + X[i] - X[j] > k)
{
int64_t p = X[i], q = X[j], r = k - c - D[i] - D[j];
u2 = min(u2, p + q + r);
u1 = max(u1, p + q - r);
v1 = max(v1, p - q - r);
v2 = min(v2, p - q + r);
}
}
bool ok = false;
for(size_t a = 0; a < n; a++)
for(size_t b = 0; b < a; b++)
if(u1 <= X[a]+X[b] and X[a]+X[b] <= u2 and v1 <= X[a]-X[b] and X[a]-X[b] <= v2)
ok = true;
if(ok)
hi = k;
else
lo = k + 1;
}
return lo;
}
Compilation message
/tmp/ccRe63v6.o: In function `main':
grader.cpp:(.text.startup+0x10d): undefined reference to `find_shortcut(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, int)'
collect2: error: ld returned 1 exit status