Submission #493995

# Submission time Handle Problem Language Result Execution time Memory
493995 2021-12-13T17:30:10 Z FerThugGato12500 Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#include "ricehub.h"
using namespace std;

bool f(int k, int n, int &p[], long long B){
	if(k==0) return true;
	int med = k/2;
	long long D = 0;
	for(int i = 0; i < k; i++){
		D+=abs(p[med]-p[i]);
	}
	long long d = D;
	for(int l = 1; l+k<=n; l++){
		D-=abs(p[med]-p[l-1]);
		med++;
		D+=abs(p[med]-p[(l+k)-1]);
		d = min(d, D);
	}
	return d <= B;
}
int besthub(int n, int L, int p[], long long B)
{
	int ini = 0, fin = n;
	while(ini+1<fin){
		int mit = (ini+fin)/2;
		if(f(mit,n, p, B)){
			ini = mit;
		}else{
			fin = mit-1;
		}
	}
	if(f(fin,n, p,B)) return fin;
	return ini;
}

Compilation message

ricehub.cpp:6:27: error: declaration of 'p' as array of references
    6 | bool f(int k, int n, int &p[], long long B){
      |                           ^
ricehub.cpp:6:30: error: expected ')' before ',' token
    6 | bool f(int k, int n, int &p[], long long B){
      |       ~                      ^
      |                              )
ricehub.cpp:6:32: error: expected unqualified-id before 'long'
    6 | bool f(int k, int n, int &p[], long long B){
      |                                ^~~~