This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "king.h"
using namespace std;
long long SendInfo(vector <int> W, vector <int> C)
{
return 1;
}
#include <set>
#include <vector>
#include <algorithm>
#include "vassal.h"
using namespace std;
static set <int> sit;
static vector <int> chair;
static int N;
void Init(long long B, vector <int> C)
{
sort(C.begin(), C.end());
copy(C.begin(), C.end(), chair.begin());
N = C.size();
for (int i = 0; i < N; i++) sit.insert(i);
}
int Maid(int w)
{
int right = N - 1, left = 0, mid = 0, res = 0;
while (left <= right) {
mid = (right + left) / 2;
if (chair[mid] > w) {
right = mid - 1;
if (right <= left) {
res = mid;
break;
}
}
else if (chair[mid] < w) {
left = mid + 1;
if (right <= left) {
res = right;
break;
}
}
else {
res = mid;
break;
}
}
auto itr = sit.upper_bound(res);
if (itr == sit.end()) {
return -1;
}
else {
int answer = *itr;
sit.erase(itr);
return answer;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |