Submission #655225

# Submission time Handle Problem Language Result Execution time Memory
655225 2022-11-03T14:55:48 Z Trumling Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include<iostream>
#include<cmath>
using namespace std;

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';

int besthub(int R, int L, int X[], long long B)
{
ll ans=1;
ll plus=R;
while(plus!=1)
{
if(ans!=1)
break;
bool pre=false;
ll curr=0;
//cout<<'\n';
for(int i=0;i<=R-plus;i++)
{
ll med;
if(!pre)
{
med=(i+i+plus)/2;
for(int j=i;j<i+plus;j++)
    curr+=abs(X[med]-X[j]);

pre=true;
}
else
{
    curr-=abs(X[i-1]-X[med]);
    med++;
    ll dif=abs(X[med]-X[med-1]);
    curr=curr+abs(i-med)*dif;
    curr=curr-(plus-med+1)*dif;
    curr+=abs(X[med]-X[i+plus-1]);
    curr-=abs(X[med-1]-x[i-1]);
}

//cout<<curr<<' ';



if(curr<=B)
{
    ans=plus;
    break;
}
}
plus--;
}
//cout<<'\n'<<ans<<'\n';
return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:42:24: error: 'x' was not declared in this scope
   42 |     curr-=abs(X[med-1]-x[i-1]);
      |                        ^