Submission #1036135

#TimeUsernameProblemLanguageResultExecution timeMemory
1036135hmm789Robots (IOI13_robots)C++14
100 / 100
1111 ms24412 KiB
#include <bits/stdc++.h> #include "robots.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); pair<int, int> p[T]; for(int i = 0; i < T; i++) { p[i].first = W[i]; p[i].second = S[i]; } sort(p, p+T); int l = 0, r = T+1, m; while(l < r) { m = (l+r)/2; priority_queue<int> pq; int idx = 0, ok = 1; for(int i = 0; i < A; i++) { while(idx < T && p[idx].first < X[i]) { pq.push(p[idx++].second); } for(int j = 0; j < m && pq.size(); j++) pq.pop(); } while(idx < T) pq.push(p[idx++].second); for(int i = B-1; i >= 0; i--) { if(pq.size() && pq.top() >= Y[i]) { ok = 0; goto ed; } for(int j = 0; j < m && pq.size(); j++) pq.pop(); } if(pq.size()) ok = 0; ed:; if(ok) r = m; else l = m+1; } if(l == T+1) return -1; else return 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...