Submission #996534

#TimeUsernameProblemLanguageResultExecution timeMemory
996534aykhnRobots (IOI13_robots)C++17
100 / 100
1314 ms20428 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X, X + A), sort(Y, Y + B); vector<int> o(T, 0); iota(o.begin(), o.end(), 0); sort(o.begin(), o.end(), [&](const int &a, const int &b) { return W[a] < W[b]; }); int l = 1, r = T + 1; priority_queue<int> ms; while (l < r) { while (!ms.empty()) ms.pop(); int mid = (l + r) >> 1; int j = 0; for (int i = 0; i < A; i++) { while (j < T && W[o[j]] < X[i]) ms.push(S[o[j]]), j++; int c = mid; while (c-- && !ms.empty()) ms.pop(); } while (j < T) ms.push(S[o[j]]), j++; for (int i = B - 1; i >= 0; i--) { int c = mid; while (c-- && !ms.empty() && ms.top() < Y[i]) ms.pop(); } if (ms.empty()) r = mid; else l = mid + 1; } return (l == T + 1 ? -1 : 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...