제출 #372953

#제출 시각아이디문제언어결과실행 시간메모리
372953Joshc로봇 (IOI13_robots)C++11
100 / 100
1847 ms25004 KiB
#include "robots.h" #include <cstdio> #include <algorithm> #include <vector> #include <queue> using namespace std; int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]) { vector<int> x, y; for (int i=0; i<a; i++) x.push_back(X[i]); for (int i=0; i<b; i++) y.push_back(Y[i]); sort(x.begin(), x.end()); sort(y.begin(), y.end()); vector<pair<int, int> > v; for (int i=0; i<t; i++) { v.emplace_back(W[i], S[i]); if ((x.empty() || W[i]>=x.back()) && (y.empty() || S[i]>=y.back())) return -1; } sort(v.begin(), v.end()); reverse(y.begin(), y.end()); int low=1, high=t, mid; while (low != high) { mid = (low+high) >> 1; priority_queue<int> pq; int cur = 0; for (int i : x) { while (cur<t && v[cur].first<i) pq.push(v[cur++].second); int z = min((int)pq.size(), mid); for (int i=0; i<z; i++) pq.pop(); } for (; cur<t; cur++) pq.push(v[cur].second); for (int i : y) { int z = 0; while (z++<mid && !pq.empty() && pq.top()<i) pq.pop(); } if (pq.empty()) high = mid; else low = mid+1; } return 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...