제출 #53318

#제출 시각아이디문제언어결과실행 시간메모리
53318imeimi2000로봇 (IOI13_robots)C++17
100 / 100
2164 ms196608 KiB
#include "robots.h" #include <algorithm> #include <queue> using namespace std; typedef pair<int, int> pii; int a, b, t; int x[50000]; int y[50000]; pii toy[1000000]; int check(int c) { priority_queue<int> pq; int j = 0; for (int i = 0; i < a; ++i) { while (j < t && toy[j].first < x[i]) pq.push(toy[j++].second); for (int k = 0; k < c && pq.size(); ++k) pq.pop(); } while (j < t) pq.push(toy[j++].second); for (int i = b; i--; ) { if (pq.size() && y[i] <= pq.top()) return 0; for (j = 0; j < c && pq.size(); ++j) pq.pop(); } return pq.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { a = A; b = B; t = T; int mx = 0, my = 0; for (int i = 0; i < a; ++i) mx = max(mx, x[i] = X[i]); for (int i = 0; i < b; ++i) my = max(my, y[i] = Y[i]); for (int i = 0; i < t; ++i) { if (mx <= W[i] && my <= S[i]) return -1; toy[i] = pii(W[i], S[i]); } sort(x, x + a); sort(y, y + b); sort(toy, toy + t); int s = 1, e = t; while (s < e) { int m = (s + e) / 2; if (check(m)) e = m; else s = m + 1; } return s; }
#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...