제출 #2349

#제출 시각아이디문제언어결과실행 시간메모리
2349kriii로봇 (IOI13_robots)C++98
100 / 100
2441 ms13936 KiB
#include "robots.h" #include <vector> #include <algorithm> #include <queue> using namespace std; vector<pair<int,int> > U; priority_queue<int> H; vector<int> P,Q; bool chk(int v) { int i,j,c; while (!H.empty()) H.pop(); for (i=j=0;i<P.size();i++){ while (j < U.size() && U[j].first < P[i]){ H.push(U[j].second); j++; } c = v; while (c > 0 && !H.empty()){ H.pop(); c--; } } for (;j<U.size();j++) H.push(U[j].second); for (i=0;i<Q.size();i++){ c = v; while (c > 0 && !H.empty()){ if (H.top() >= Q[i]) return false; H.pop(); c--; } if (H.empty()) break; } return H.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { int i,x=0,y=0; for (i=0;i<A;i++){ P.push_back(X[i]); x = max(x,X[i]); } sort(P.begin(),P.end()); for (i=0;i<B;i++){ Q.push_back(Y[i]); y = max(y,Y[i]); } sort(Q.rbegin(),Q.rend()); for (i=0;i<T;i++){ if (W[i] >= x && S[i] >= y) return -1; U.push_back(make_pair(W[i],S[i])); } sort(U.begin(),U.end()); int l = 1, r = T, m = 1; while (l < r){ m = (l + r) / 2; if (chk(m)) r = m - 1; else l = m + 1; } while (chk(m)) m--; while (!chk(m)) m++; return m; }
#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...