제출 #56400

#제출 시각아이디문제언어결과실행 시간메모리
56400aquablitz11로봇 (IOI13_robots)C++14
76 / 100
3043 ms14308 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; int A, B, T; int *X, *Y, *W, *S, ix[MT]; bool used[MT]; bool check(int tim) { for (int i = 0; i < T; ++i) { ix[i] = i; used[i] = false; } int tt = 0; // weak robot matching sort(ix, ix+T, [&] (int a, int b) { return W[a] < W[b]; }); int j = 0; priority_queue<pii> Q; for (int i = 0; i < A; ++i) { while (j < T && W[ix[j]] < X[i]) { Q.push({S[ix[j]], ix[j]}); ++j; } for (int cnt = 0; cnt < tim && !Q.empty(); ++cnt) { used[Q.top().second] = true; ++tt; Q.pop(); } } // small robot matching sort(ix, ix+T, [&] (int a, int b) { return S[a] < S[b]; }); j = 0; while (!Q.empty()) Q.pop(); for (int i = 0; i < B; ++i) { while (j < T && S[ix[j]] < Y[i]) { if (!used[ix[j]]) Q.push({W[ix[j]], ix[j]}); ++j; } for (int cnt = 0; cnt < tim && !Q.empty(); ++cnt) { used[Q.top().second] = true; ++tt; Q.pop(); } } return tt == T; } 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, ::W = W, ::S = S; sort(X, X+A); sort(Y, Y+B); int b = 1, 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...