Submission #852787

#TimeUsernameProblemLanguageResultExecution timeMemory
852787ntkphongRobots (IOI13_robots)C++14
100 / 100
1354 ms18208 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; const int INF = 2000000000; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X, X + A); sort(Y, Y + B); array<int, 2> R[T]; for(int i = 0; i < T; i ++) R[i] = {W[i], S[i]}; sort(R, R + T); auto check = [&](int x) { priority_queue<int> pq; int num = 0; while(num < A && X[num] <= R[0][0]) num ++ ; for(int i = 0, j = 0; i < T; i = j + 1) { for(j = i; j + 1 < T && R[j + 1][0] == R[i][0]; ) j ++ ; for(int k = i; k <= j; k ++) pq.push(R[k][1]); while(num < A && X[num] <= (j + 1 < T ? R[j + 1][0] : INF)) { for(int k = 1; k <= x && !pq.empty(); k ++) pq.pop(); num ++ ; } } for(int i = B - 1; i >= 0; i --) { if(!pq.empty() && pq.top() >= Y[i]) return 0; for(int j = 1; j <= x && !pq.empty(); j ++) pq.pop(); } return (pq.size() == 0 ? 1 : 0); }; int low = 1, high = T; while(low <= high) { int mid = (low + high) / 2; if(!check(mid)) low = mid + 1; else high = mid - 1; } return (low > T ? -1 : low); }
#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...