Submission #467673

# Submission time Handle Problem Language Result Execution time Memory
467673 2021-08-24T00:55:31 Z jam_xd_ Rice Hub (IOI11_ricehub) C++17
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include <iostream>
#include <vector>
 
 
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++){

        vector<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:19:3: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   19 |   sort(diferencias.begin(), diferencias.end());
      |   ^~~~
      |   qsort
ricehub.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int k=0;k<diferencias.size();k++){
      |               ~^~~~~~~~~~~~~~~~~~~