이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "king.h"
long long SendInfo(std::vector<int> W, std::vector<int> C) {
return 0;
}
#include "vassal.h"
#include <algorithm>
std::vector<std::pair<int, int>> chair;
void Init(long long B, std::vector<int> C){
int N = C.size();
for (int i = 0; i < N; i++) {
chair.push_back(std::pair<int,int>(C[i], i));
}
sort(chair.begin(), chair.end());
}
int findidx(int first, int last, int weight) {
int mid;
while (first <= last) {
mid = (first + last) / 2;
if (chair[mid].first > weight) {
if (mid != 0 && chair[mid - 1].first < weight) {
return mid;
}
last = mid - 1;
}
else if (chair[mid].first == weight) {
if (mid != 0 && chair[mid - 1].first == weight) {
last = mid - 1;
}
else {
return mid;
}
}
else {
first = mid + 1;
}
}
return -1;
}
int Maid(int W){
int first = 0, last = (int)chair.size() - 1;
int idx;
while (1) {
idx = findidx(first, last, W);
if (idx == -1) {
return -1;
}
if (chair[idx].second != -1) {
chair[idx].second = -1;
return idx;
}
else {
first = idx + 1;
}
}
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |