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"
#include <algorithm>
int mylower_bound(std::vector<int>& c, int n, int val) {
int start = 0, end = n;
while (start <= end) {
int mid = (start + end) / 2;
if (c[mid] < val) start = mid + 1;
else end = mid - 1;
}
return start;
}
long long SendInfo(std::vector<int> W, std::vector<int> C) {
int N = W.size();
sort(W.begin(), W.end());
sort(C.begin(), C.end());
long long cansitbegin = -2;
long long cansitend = -2;
int X = N - 1;
for (int i = N - 1; i >= 0; --i) {
int index = mylower_bound(C, X, W[i]);
if (index <= X) {
if (cansitend == -2) {
cansitend = i;
cansitbegin = i;
}
else {
cansitbegin = i;
}
X--;
}
}
return W[cansitend] * 1000001 + W[cansitbegin];
}
#include "vassal.h"
int startindex;
int start, end;
void Init(long long B, std::vector<int> C){
int N = C.size();
start = B % 1000001;
end = B / 1000001;
for (int i = 0; i < N; ++i) {
if (C[i] >= start) {
startindex = i;
break;
}
}
}
int Maid(int W){
if (W < start || W > end) {
return -1;
}
else{
return startindex++;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |