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"
long long SendInfo(std::vector<int> W, std::vector<int> C) {
return 0;
}
#include "vassal.h"
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int N, cnt;
int parent[101010];
vector<pii> CC;
int Find(int a) {
if (parent[a] == a) return a;
return parent[a] = Find(parent[a]);
}
void Union(int a, int b) {
if (Find(a) == Find(b)) return;
parent[Find(b)] = Find(a);
}
void Init(long long B, std::vector<int> C){
N = C.size();
CC.resize(N);
for (int i=0; i<N; i++) {
CC[i].va = C[i];
CC[i].vb = i;
}
sort(CC.begin(), CC.end());
for (int i=0; i<=N; i++) parent[i] = i;
return;
}
int Maid(int W){
++cnt;
vector<pii>::iterator lb = lower_bound(CC.begin(), CC.end(), pii(W, 0));
int idx = lb - CC.begin();
if (Find(idx) == N) return -1;
int ans = CC[Find(idx)].vb;
Union(Find(idx)+1, Find(idx));
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |