답안 #224669

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224669 2020-04-18T14:44:05 Z Amy313 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{vector<int>V;
	int maxi= 0, c, a;
	long long cp = B;
	for(int i=1; i<=L; i++)
	{
		c = 0;
		cp = B;	

		for(int j=0; j<R; j++)
		{
			a = abs(i-X[j]);
			V.push_back(a);
		}
		sort(V.begin(), V.end());
		for(int i=0; i<V.size(); i++)
		{
			if(V[j]<=cp)
			{
				cp-=V[j];
				c++;
			}
			else
			{
				break;
			}
		}
		if(c>maxi)
		{
			maxi = c;
		}
	}
  return maxi;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:19:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<V.size(); i++)
                ~^~~~~~~~~
ricehub.cpp:21:9: error: 'j' was not declared in this scope
    if(V[j]<=cp)
         ^