#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 |
1 |
Correct |
10 ms |
800 KB |
Correct |
2 |
Correct |
10 ms |
1060 KB |
Correct |
3 |
Correct |
11 ms |
804 KB |
Correct |
4 |
Correct |
10 ms |
972 KB |
Correct |
5 |
Correct |
11 ms |
1016 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
4156 KB |
Correct |
2 |
Correct |
92 ms |
6468 KB |
Correct |
3 |
Correct |
100 ms |
6980 KB |
Correct |
4 |
Correct |
97 ms |
6988 KB |
Correct |
5 |
Correct |
98 ms |
6864 KB |
Correct |
6 |
Correct |
96 ms |
7000 KB |
Correct |
7 |
Correct |
99 ms |
6988 KB |
Correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
4172 KB |
Correct |
2 |
Correct |
111 ms |
6440 KB |
Correct |
3 |
Correct |
108 ms |
6948 KB |
Correct |
4 |
Correct |
112 ms |
7000 KB |
Correct |
5 |
Correct |
111 ms |
6988 KB |
Correct |
6 |
Correct |
113 ms |
6992 KB |
Correct |
7 |
Correct |
108 ms |
6988 KB |
Correct |
8 |
Correct |
102 ms |
6996 KB |
Correct |