Submission #1287530

#TimeUsernameProblemLanguageResultExecution timeMemory
1287530repmannRice Hub (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
inline int besthub(int N, int M, int *X, ll K)
{
  int sol = 0;
  ll temp = 0;
  for(int i = 0, l = 0, r = 0; i < N; i++)
  {
    if(i) temp += (i - l - (r - i + 1LL)) * (X[i] - X[i - 1]);
    while((l < i) && (temp > K))
    {
      temp -= X[i] - X[l];
      l++;
    }
    while(((r + 1) < N) && ((temp + X[r + 1] - X[i]) <= K))
    {
      temp += X[r + 1] - X[i];
      r++;
    }
    while((l < i) && ((r + 1) < N) && ((X[i] - X[l]) > (X[r + 1] - X[i])))
    {
      if(temp <= K) sol = max(r - l + 1, sol);
      temp -= X[i] - X[l];
      l++;
      while(((r + 1) < N) && ((temp + X[r + 1] - X[i]) <= K))
      {
        temp += X[r + 1] - X[i];
        r++;
      }
    }
    if(temp <= K) sol = max(r - l + 1, sol);
  }
  return sol;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccboY6f2.o: in function `main':
grader.cpp:(.text.startup+0xaa): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status