Submission #510011

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