Submission #1088694

#TimeUsernameProblemLanguageResultExecution timeMemory
1088694VMaksimoski008Robots (IOI13_robots)C++17
100 / 100
1274 ms24452 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { vector<array<int, 2> > v; for(int i=0; i<T; i++) v.push_back({ W[i], S[i] }); sort(X, X + A); sort(Y, Y + B); sort(v.begin(), v.end()); int l=1, r=T, ans=-1; while(l <= r) { int mid = (l + r) / 2; bool ok = 1; priority_queue<int> pq; int j = 0; for(int i=0; i<A; i++) { while(j < T && v[j][0] < X[i]) pq.push(v[j][1]), j++; for(int k=0; k<mid&&!pq.empty(); k++) pq.pop(); } for(int i=j; i<T; i++) pq.push(v[i][1]); for(int i=B-1; i>=0&&ok; i--) for(int k=0; k<mid&&!pq.empty(); k++) if(pq.top() < Y[i]) pq.pop(); else ok = 0; if(pq.empty()) ans = mid, r = mid - 1; else l = 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...