Submission #1287585

#TimeUsernameProblemLanguageResultExecution timeMemory
1287585repmannRice Hub (IOI11_ricehub)C++20
68 / 100
1095 ms588 KiB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int besthub(int N, int M, int X[], ll K)
{
  int l = 2, r = N, s, ret = 1;
  auto OK = [&]()
  {
    for(int i = s - 1; i < N; i++)
    {
      int med = (i - s + 1 + i) >> 1;
      ll temp = 0;
      for(int j = i - s + 1; j <= i; j++) temp += abs(X[j] - X[med]);
      if(temp <= K) return true;
    }
    return false;
  };
  while(l <= r)
  {
    s = (l + r) >> 1;
    if(OK()) {l = s + 1; ret = s;}
    else r = s - 1;
  }
  return ret;
}
//int main()
//{
//  int n, m;
//  ll k;
//  cin >> n >> m >> k;
//  int x[n];
//  for(int i = 0; i < n; i++) cin >> x[i];
//  cout << besthub(n, m, x, k) << '\n';
//  return 0;
//}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...