Submission #112983

# Submission time Handle Problem Language Result Execution time Memory
112983 2019-05-23T01:56:50 Z CaroLinda Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "ricehub.h"

#define lp(i,a,b) for(int i = a ; i < b ; i++)
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mk make_pair

const int inf = 1e9 + 10 ;
const int MAXN = 1e5 + 10 ;

using namespace std ;

int b , l , r , x[MAXN] ;
int pref[MAXN] , suf[MAXN] ;

int m(int a , int b)
{ return (a+b)/2 ; }

ll d(int a , int b  )
{ return abs( x[a] - x[b] ) ; }

ll c1(int a , int b)
{ return pref[b] - pref[a-1] - (b-a+1) * d(a,1) ; }

ll c2(int a , int b)
{ return suf[a] - suf[b+1] - (b-a+1) * d(b,r) ; }

bool test(int tam)
{

  int ini = 1 , fim = tam ;
 
  while( fim <= r )
  {
    int now = m(ini,fim) ;
    if( c1( ini , now ) + c2( now , fim ) <= b ) 
      return true ;
    ini ++ , fim++ ;
  }
  
  return false ;

}

ll ricehub(int R , int L , int X[] , int B )
{
  b = B , r = R , l = L ;
  lp(i,1,r+1) x[i] = X[i-1] ;

  sort( x+1 , x+r+1 ) ;

  lp(i,1,r+1) pref[i] = pref[i-1] + d(i,1) ;

  for(int i = r ; i > 0 ; i-- ) suf[i] = suf[i+1] + d(i,r) ;

  int ini = 1 , fim = r , best = 1;

  while( ini <= fim )
  {
    if( test( m(ini,fim) ) )
    {
      best = m(ini,fim) ;
      ini = m(ini,fim) + 1 ;
    }

    else fim = m(ini,fim) - 1;

  }

  return best ;

}


Compilation message

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