답안 #467677

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467677 2021-08-24T01:01:48 Z jam_xd_ 쌀 창고 (IOI11_ricehub) C++17
컴파일 오류
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 suma_d=0, campos=0;
	long jamon=0;//auxiliar
 
	for(int i=0;i<R;i++){

        deque<long long>diferencias(R);
		for(int j=0;j<R;j++)differencias[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 = 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, int*, long long int)':
ricehub.cpp:16:23: error: 'differencias' was not declared in this scope; did you mean 'diferencias'?
   16 |   for(int j=0;j<R;j++)differencias[j] = abs(X[i]-X[j]);
      |                       ^~~~~~~~~~~~
      |                       diferencias
ricehub.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for(int k=0;k<diferencias.size();k++){
      |               ~^~~~~~~~~~~~~~~~~~~