Submission #614006

# Submission time Handle Problem Language Result Execution time Memory
614006 2022-07-30T16:24:25 Z chirathnirodha Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
#define PB push_back 
typedef long long ll;

int besthub(int R, int L, int X[], long long B){
  int a=0;int b=0;
  int ans=1;
  ll curcos=0;
  while(a<n && b<n){
    int pm=(a+b)/2;
    if(curcos<=B){
      ans=max(ans,b-a+1);
      if(b==n-1)break;
      b++;
      curcos+=X[b]-X[pm];
    }
    else{
      a++;
      curcos-=X[pm]-X[b];
    }
    int nm=(a+b)/2;
    curcos+=(X[nm]-X[pm])*((nm-a)-(b-pm));
  }
  return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:11:11: error: 'n' was not declared in this scope
   11 |   while(a<n && b<n){
      |           ^