Submission #467670

# Submission time Handle Problem Language Result Execution time Memory
467670 2021-08-24T00:42:56 Z jam_xd_ Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include <bits/stdc++.h>
 
 
using namespace std; //si solo era esto me muero >:v.
 
int besthub(int R, int L, int X[], long long B)
{
	
	long long suma_d=0, campos=0;
	long long jamon=0;//auxiliar
 
	for(int i=0;i<R;i++){

        long long diferencias[R];
		for(int j=0;j<R;j++)diferencias[j] = abs(X[i]-X[j]);
		
		sort(diferencias.begin(), diferencias.end());
		for(int k=0;k<diferencias.size();k++){
			if(suma_d + diferencias[k] <= B){
				suma_d += diferencias[k];
				campos++;
			}else break;
		}

		long long maximo = max(jamon, campos);
		jamon = maximo;
		suma_d=0;
		campos=0;
	}
  return jamon;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:18:20: error: request for member 'begin' in 'diferencias', which is of non-class type 'long long int [R]'
   18 |   sort(diferencias.begin(), diferencias.end());
      |                    ^~~~~
ricehub.cpp:18:41: error: request for member 'end' in 'diferencias', which is of non-class type 'long long int [R]'
   18 |   sort(diferencias.begin(), diferencias.end());
      |                                         ^~~
ricehub.cpp:19:29: error: request for member 'size' in 'diferencias', which is of non-class type 'long long int [R]'
   19 |   for(int k=0;k<diferencias.size();k++){
      |                             ^~~~