Submission #56411

#TimeUsernameProblemLanguageResultExecution timeMemory
56411aquablitz11Robots (IOI13_robots)C++14
90 / 100
2226 ms66560 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; using pii = pair<int, int>; const int N = 50010; const int MT = 1000010; const int INF = 2e9+1; #define F first #define S second int A, B, T, *X, *Y; vector<pii> toys; bool check(int lim) { priority_queue<int> Q; int j = 0; for (int i = 0; i < A; ++i) { while (j < T && toys[j].F < X[i]) Q.push(toys[j++].S); for (int c = 0; c < lim && !Q.empty(); ++c) Q.pop(); } while (j < T) Q.push(toys[j++].S); for (int i = B-1; i >= 0; --i) { if (!Q.empty() && Q.top() >= Y[i]) return false; for (int c = 0; c < lim && !Q.empty(); ++c) Q.pop(); } return Q.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { ::A = A, ::B = B, ::T = T, ::X = X, ::Y = Y; sort(X, X+A); sort(Y, Y+B); for (int i = 0; i < T; ++i) toys.emplace_back(W[i], S[i]); sort(toys.begin(), toys.end()); int b = 1; int e = T+1; while (b < e) { int m = (b+e)/2; if (check(m)) e = m; else b = m+1; } return b == T+1 ? -1 : b; }
#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...