답안 #149240

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149240 2019-09-01T06:02:08 Z Little Piplup(#3742, gratus907, DHdroid, coffeetea99) King of Chairs (FXCUP4_chairs) C++17
컴파일 오류
0 ms 0 KB
#include "king.h"
long long SendInfo(std::vector<int> W, std::vector<int> C) 
{
	int N = W.size();
	std::sort(C.begin(),C.end());
	std::sort(W.begin(),W.end());
	std::vector <bool> able(N, false);
	std::vector <bool> FC(N, false);
	long long maxweight = 0;
	for (int i = 0; i<N; i++)
	{
		int u = std::lower_bound(C.begin(),C.end(),W[i])-C.begin();
		while(u < N && FC[u])
		{
			u++;
		}
		if (u == N)
		{
			continue;
		}
		else 
		{
			FC[u] = 1;
			maxweight = std::max(maxweight,(long long)W[i]);
		}
	}
	return maxweight;
}
#include "vassal.h"
#include <algorithm>
long long BB;
std::vector <int> Chairs;
bool fullchair[101010];
void Init(long long B, std::vector<int> C)
{
	int N = C.size();
	BB = B;
	Chairs = C;
	std::sort(Chairs.begin(),Chairs.end());
}

int Maid(int W)
{
	if (W > BB)
		return -1;
	int N = Chairs.size();
	int u = std::lower_bound(Chairs.begin(),Chairs.end(),W)-Chairs.begin();
	while(u < N && fullchair[u])
	{
		u++;
	}
	if (u == N)
	{
		return -1;
	}
	else 
	{
		fullchair[u] = 1;
		return u;
	}
}

Compilation message

king.cpp: In function 'long long int SendInfo(std::vector<int>, std::vector<int>)':
king.cpp:5:7: error: 'sort' is not a member of 'std'
  std::sort(C.begin(),C.end());
       ^~~~
king.cpp:6:7: error: 'sort' is not a member of 'std'
  std::sort(W.begin(),W.end());
       ^~~~

vassal.cpp: In function 'void Init(long long int, std::vector<int>)':
vassal.cpp:8:6: warning: unused variable 'N' [-Wunused-variable]
  int N = C.size();
      ^