Submission #467661

# Submission time Handle Problem Language Result Execution time Memory
467661 2021-08-24T00:20:17 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, long long X[], long long B)
{
	
	long long suma_d=0, campos=0;
	long long jamon=0;//auxiliar
 
	for(int i=0;i<R;i++){
        deque<long long>diferencias;
		for(int j=0;j<R;j++){
			long long dif=0;
			/*dif = i-X[j];
			  if(dif <= 0)dif = dif * -1;
			*/
			dif = abs(X[i]-X[j]);
			diferencias.push_back(dif);
		}
		sort(diferencias.begin(), diferencias.end());
	
		for(int k=0;k<diferencias.size();k++){
			if(suma_d + diferencias[k] <= B){
				suma_d = suma_d + diferencias[k];
				campos++;
			}else break;
		}
		long long maximo = max(jamon, campos);
		jamon = maximo;
		suma_d=0;
		campos=0;
		//comparar anterior y el de ahora 
		//y me quedo con el mayor.
			
	}
    
  return jamon;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, long long int*, long long int)':
ricehub.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for(int k=0;k<diferencias.size();k++){
      |               ~^~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccCZGW5z.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status