Submission #510009

#TimeUsernameProblemLanguageResultExecution timeMemory
510009jesus_coconutRobots (IOI13_robots)C++17
76 / 100
3020 ms14676 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; int const kT = 1000005; bool used[kT]; int perm[kT]; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X, X + A); sort(Y, Y + B); iota(perm, perm + T, 0); priority_queue<pair<int, int>> pq; auto check = [&](int t) -> bool { memset(used, 0, sizeof used); sort(perm, perm + T, [&](int a, int b) { return make_tuple(W[a], S[a]) < make_tuple(W[b], S[b]); }); pq = priority_queue<pair<int, int>>(); int p = 0; for (int i = 0; i < A; ++i) { while (p < T && W[perm[p]] < X[i]) { pq.emplace(S[perm[p]], perm[p]); ++p; } for (int j = 0; j < t && !pq.empty(); ++j) { auto [s, idx] = pq.top(); used[idx] = true; pq.pop(); } } sort(perm, perm + T, [&](int a, int b) { return make_tuple(S[a], W[a]) < make_tuple(S[b], W[b]); }); pq = priority_queue<pair<int, int>>(); p = 0; for (int i = 0; i < B; ++i) { while (p < T && S[perm[p]] < Y[i]) { if (!used[perm[p]]) { pq.emplace(W[perm[p]], perm[p]); } ++p; } for (int j = 0; j < t && !pq.empty(); ++j) { auto [w, idx] = pq.top(); used[idx] = true; pq.pop(); } } return all_of(used, used + T, [](bool b) { return b; }); }; int lo = 0, hi = T + 1; while (lo < hi) { int mid = (lo + hi) / 2; if (check(mid)) { hi = mid; } else lo = mid + 1; } if (lo > T) return -1; else return lo; }
#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...