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 <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include "vassal.h"
using namespace std;
static multiset <int> sit;
static vector <pair<int, int>> chair;
static int N;
void Init(long long B, vector <int> C)
{
N = C.size();
chair.resize(N);
for (int i = 0; i < N; i++) chair.push_back(make_pair(C[i], i));
for (int i = 0; i < N; i++) sit.insert(chair[i].first);
}
int Maid(int w)
{
int left = 0, right = N, mid = 0;
auto itr = sit.lower_bound(w);
if (itr == sit.end()) {
return -1;
}
else {
int ans = *itr; //고른 의자 무게
int idx = 0; //고른 의자가 현재의자배열의 어디에 있는가
while (right <= left) {
if (ans < chair[mid].first) {
right = mid - 1;
}
else if (chair[mid].first < ans) {
left = mid + 1;
}
else {
idx = mid;
}
}
int chair_num = chair[idx].second; //고른 의자의 원래 배열의 인덱스
chair.erase(chair.begin()+idx);
sit.erase(sit.find(ans));
return chair_num;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |