제출 #59153

#제출 시각아이디문제언어결과실행 시간메모리
59153aome로봇 (IOI13_robots)C++17
100 / 100
2667 ms39192 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 = 1, r = T; 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 r = mid; } 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 = l; 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 = l; while (cur && pq.size() && pq.top() < Y[i]) { pq.pop(), cur--; } } if (pq.size() == 0) return l; return -1; }
#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...