답안 #224668

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224668 2020-04-18T14:42:58 Z Amy313 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
#include "ricehub.h"
#include<bits/stdc++.h>
int besthub(int R, int L, int X[], long long B)
{
	int maxi= 0, c, a;
	long long cp = B;
	vector<int>V;
	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:7:2: error: 'vector' was not declared in this scope
  vector<int>V;
  ^~~~~~
ricehub.cpp:7:2: note: suggested alternative:
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from ricehub.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:216:11: note:   'std::vector'
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^~~~~~
ricehub.cpp:7:9: error: expected primary-expression before 'int'
  vector<int>V;
         ^~~
ricehub.cpp:15:4: error: 'V' was not declared in this scope
    V.push_back(a);
    ^
ricehub.cpp:17:8: error: 'V' was not declared in this scope
   sort(V.begin(), V.end());
        ^
ricehub.cpp:17:3: error: 'sort' was not declared in this scope
   sort(V.begin(), V.end());
   ^~~~
ricehub.cpp:17:3: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from ricehub.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:4856:5: note:   'std::sort'
     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
     ^~~~
ricehub.cpp:20:9: error: 'j' was not declared in this scope
    if(V[j]<=cp)
         ^