제출 #56417

#제출 시각아이디문제언어결과실행 시간메모리
56417aquablitz11로봇 (IOI13_robots)C++14
100 / 100
2251 ms13108 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; using pii = pair<int, int>; #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.emplace(toys[j++].S); for (int c = 0; c < lim && !Q.empty(); ++c) Q.pop(); } while (j < T) Q.emplace(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); //toys.reserve(T); 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...