# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
544981 | cig32 | Robots (IOI13_robots) | C++17 | 1915 ms | 30620 KiB |
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 "robots.h"
#include <algorithm>
#include <vector>
#include <queue>
bool special(std::pair<int, int> x, std::pair<int, int> y) {
return x.second < y.second;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
std::sort(X, X + A);
std::sort(Y, Y + B);
int lb = 1, rb = T + 1;
std::pair<int, int> toys[T];
for(int i=0; i<T; i++) {
toys[i] = {W[i], S[i]};
}
std::sort(toys, toys + T);
while(lb < rb) {
int mid = (lb + rb) >> 1;
int prog = -1;
std::priority_queue<std::pair<int, int> > pq;
bool done[T];
for(int i=0; i<T; i++) done[i] = 0;
for(int i=0; i<A; i++) {
while(prog + 1 < T && toys[prog + 1].first < X[i]) {
pq.push({toys[prog + 1].second, prog + 1});
prog++;
}
for(int j=0; j<mid; j++) {
if(pq.empty()) break;
done[pq.top().second] = 1;
pq.pop();
}
}
std::vector<std::pair<int, int> > rem;
for(int i=0; i<T; i++) {
if(!done[i]) rem.push_back(toys[i]);
}
sort(rem.begin(), rem.end(), special);
prog = -1;
while(pq.size()) pq.pop();
int kek = 0;
int cnt = 0;
for(int i=0; i<B; i++) {
while(prog + 1 < rem.size() && rem[prog + 1].second < Y[i]) {
cnt++;
prog++;
}
for(int j=0; j<mid; j++) {
if(!cnt) break;
kek++;
cnt--;
}
}
for(int i=0; i<T; i++) kek += done[i];
if(kek == T) rb = mid;
else lb = mid + 1;
}
return (lb == T + 1 ? -1 : lb);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |