제출 #538042

#제출 시각아이디문제언어결과실행 시간메모리
538042pavement로봇 (IOI13_robots)C++17
100 / 100
1906 ms28024 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; bitset<1000005> yes; ii M[1000005]; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X, X + A); sort(Y, Y + B); for (int i = 0; i < T; i++) M[i] = make_pair(W[i], S[i]); sort(M, M + T); int lo = 1, hi = T, ans = -1; for (int i = 0; i < T; i++) tie(W[i], S[i]) = M[i]; while (lo <= hi) { yes.reset(); priority_queue<ii> pq; int mid = (lo + hi) / 2, idx = 0; for (int i = 0; i < A; i++) { for (; idx < T && W[idx] < X[i]; idx++) pq.emplace(S[idx], idx); for (int j = 0; j < mid && !pq.empty(); j++) { yes[pq.top().second] = 1; pq.pop(); } } priority_queue<int, vector<int>, greater<int> > pq2; for (int i = 0; i < T; i++) if (!yes[i]) pq2.push(S[i]); for (int i = 0; i < B; i++) for (int j = 0; j < mid && !pq2.empty() && pq2.top() < Y[i]; j++) pq2.pop(); if (pq2.empty()) ans = mid, hi = mid - 1; else lo = mid + 1; } return ans; }
#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...