제출 #383357

#제출 시각아이디문제언어결과실행 시간메모리
383357Iwanttobreakfree쌀 창고 (IOI11_ricehub)C++17
컴파일 에러
0 ms0 KiB
#include "ricehub.h"
#include <vector>
#include <algorithm>
using namespace std;
int besthub(int R, int L, int X[], long long B){
	vector<int> v(R);
	for(int i=0;i<R;i++)v[i]=x[i];
	sort(v.begin(),v.end());
	int l=0,r=R,maxi=0;
	while(l<=r){
		int mid(r-l)/2+l;
		long long int i=mid+1,sum=0,c=0;
		while(i<R&&sum<B){
			sum+=v[i]-v[mid];
			i++;
			c++;
		}
		if(c>maxi){
			maxi=c;
			r=mid-1;
		}
		else l=mid+1;
	}
  return maxi;
}

컴파일 시 표준 에러 (stderr) 메시지

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:7:27: error: 'x' was not declared in this scope
    7 |  for(int i=0;i<R;i++)v[i]=x[i];
      |                           ^
ricehub.cpp:11:15: error: expected ',' or ';' before '/' token
   11 |   int mid(r-l)/2+l;
      |               ^