Submission #59152

#TimeUsernameProblemLanguageResultExecution timeMemory
59152aomeRobots (IOI13_robots)C++17
0 / 100
4 ms644 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; const int N = 1000005; int P[N]; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { for (int i = 0; i < T; ++i) P[i] = i; sort(X, X + A); sort(Y, Y + B); sort(P, P + T, [&] (int x, int y) { return W[x] < W[y]; }); int l = 0, r = T; bool haveSolution = 0; while (l < r) { int mid = (l + r) >> 1; int ptr = 0; priority_queue<int> pq; for (int i = 0; i < A; ++i) { while (ptr < T && W[P[ptr]] < X[i]) pq.push(S[P[ptr++]]); int cur = mid; while (cur && pq.size()) pq.pop(), cur--; } while (ptr < T) pq.push(S[P[ptr++]]); for (int i = B - 1; i >= 0; --i) { int cur = mid; while (cur && pq.size() && pq.top() < Y[i]) { pq.pop(), cur--; } } if (pq.size()) l = mid + 1; else { haveSolution = 1, r = mid; } } if (!haveSolution) return -1; return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...