답안 #151984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151984 2019-09-05T19:21:52 Z minty99 King of Chairs (FXCUP4_chairs) C++17
0 / 100
49 ms 3928 KB
#include "king.h"
#include <algorithm>

long long SendInfo(std::vector<int> W, std::vector<int> C) {
	sort(W.begin(), W.end());
	sort(C.begin(), C.end());
	int last = 0;
	long long ans = 0;
	for(int w : W)
	{
		while(last < C.size() && w > C[last]) last++;
		if(last < C.size() && w <= C[last]) ans = w;
	}
	return ans;
}
#include "vassal.h"
#include <algorithm>
#include <utility>
typedef std::pair<int, int> pii;

long long BB;
std::vector<pii> CC;
int isSeated[1100000];
void Init(long long B, std::vector<int> C){
	int N = C.size();
	BB = B;
	for(int i = 0; i < N; i++)
		CC.emplace_back(C[i], i);
	sort(CC.begin(), CC.end());
}

int Maid(int W) {
	if(W > BB) return -1;
	auto it = lower_bound(CC.begin(), CC.end(), pii(W, -1));
	int orig_pos = it->second, pos = it->second;
	while(isSeated[pos] > 0) pos = isSeated[pos];
	pos++;
	if(pos >= CC.size()) return -1;
	isSeated[orig_pos] = pos;
	return pos;
}

Compilation message

king.cpp: In function 'long long int SendInfo(std::vector<int>, std::vector<int>)':
king.cpp:11:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(last < C.size() && w > C[last]) last++;
         ~~~~~^~~~~~~~~~
king.cpp:12:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(last < C.size() && w <= C[last]) ans = w;
      ~~~~~^~~~~~~~~~

vassal.cpp: In function 'int Maid(int)':
vassal.cpp:23:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(pos >= CC.size()) return -1;
     ~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 760 KB Wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 41 ms 3708 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 49 ms 3928 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -