Submission #149076

# Submission time Handle Problem Language Result Execution time Memory
149076 2019-09-01T05:42:21 Z 20190901(#3597, tongnamuu, jf297, upple1) King of Chairs (FXCUP4_chairs) C++17
0 / 100
47 ms 3008 KB
#include "king.h"
#include <algorithm>
int mylower_bound(std::vector<int>& c, int n, int val) {
	int start = 0, end = n;
	while (start <= end) {
		int mid = (start + end) / 2;
		if (c[mid] < val) start = mid + 1;
		else end = mid - 1;
	}
	return start;
}
long long SendInfo(std::vector<int> W, std::vector<int> C) {
	int N = W.size();
	sort(W.begin(), W.end());
	sort(C.begin(), C.end());
	long long cansitbegin = -2;
	long long cansitend = -2;
	int X = N - 1;
	for (int i = N - 1; i >= 0; --i) {
		int index = mylower_bound(C, X, W[i]);
		if (index <= X) {
			if (cansitend == -2) {
				cansitend = i;
				cansitbegin = i;
			}
			else {
				cansitbegin = i;
			}
			X--;
		}
	}
	return W[cansitend] * 1000001 + W[cansitbegin];
}
#include "vassal.h"

int startindex;
int start, end;
void Init(long long B, std::vector<int> C){
	int N = C.size();
	start = B % 1000001;
	end = B / 1000001;
	for (int i = 0; i < N; ++i) {
		if (C[i] >= start) {
			startindex = i;
			break;
		}
	}
}

int Maid(int W){
	if (W < start || W > end) {
		return -1;
	}
	else{
		return startindex++;
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1064 KB Wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 43 ms 2496 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 47 ms 3008 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -