Submission #151976

# Submission time Handle Problem Language Result Execution time Memory
151976 2019-09-05T18:59:10 Z minty99 King of Chairs (FXCUP4_chairs) C++17
0 / 100
46 ms 5280 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(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;
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;
	int pos = lower_bound(CC.begin(), CC.end(), pii(W, -1)) - CC.begin();
	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++;
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 780 KB Correct
2 Runtime error 4 ms 764 KB Execution failed because the return code was nonzero
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 41 ms 5272 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 46 ms 5280 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -