답안 #148895

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148895 2019-09-01T05:20:14 Z 본인 방금 올솔하는 상상함(#3610, gs18113, dennisstar, red1108) King of Chairs (FXCUP4_chairs) C++17
0 / 100
68 ms 5700 KB
#include "king.h"
#include<algorithm>
using namespace std;
long long SendInfo(vector<int> W, vector<int> C) {
	int N = W.size();
	sort(W.begin(), W.end());
	sort(C.begin(), C.end());
	int j=0,cnt=0,bef=-1;
	long long ret=0;


	for(int i=0;i<N;i++,j++){
		while(j<C.size()&&W[i]>C[j]) j++;
		if(j<C.size()) {
			if(bef!=W[i]) cnt=1;
			else cnt++;
			ret=(W[i]<<20)+cnt;
			bef = W[i];
		}
		else break;
	}
	return ret;
}
#include "vassal.h"
#include <bits/stdc++.h>
using namespace std;
long long Wmax, nmax;
set<pair<int,int>> se;
int cnt;
void Init(long long B, vector<int> C){
	for(int i=0;i<C.size();i++){
		se.insert(make_pair(C[i],i));
	}
	nmax = B&((1<<20)-1);
	Wmax = B>>20;
}

int Maid(int W){
	if(W<Wmax){
		auto it = se.lower_bound(make_pair(W,0));
		int ret = it->second;
		se.erase(it);
		return ret;
	}
	if(W==Wmax){
		if(cnt>=nmax) return -1;
		cnt++;
		auto it = se.lower_bound(make_pair(W,0));
		int ret = it->second;
		se.erase(it);
		return ret;
	}
	return -1;
}

Compilation message

king.cpp: In function 'long long int SendInfo(std::vector<int>, std::vector<int>)':
king.cpp:13:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(j<C.size()&&W[i]>C[j]) j++;
         ~^~~~~~~~~
king.cpp:14:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(j<C.size()) {
      ~^~~~~~~~~

vassal.cpp: In function 'void Init(long long int, std::vector<int>)':
vassal.cpp:8:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<C.size();i++){
              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 1056 KB Wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 68 ms 5700 KB Wrong
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 43 ms 3008 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -