제출 #1077917

#제출 시각아이디문제언어결과실행 시간메모리
1077917juicy로봇 (IOI13_robots)C++17
100 / 100
1331 ms22496 KiB
#include "robots.h" #include <bits/stdc++.h> int putaway(int a, int b, int t, int *x, int *y, int *w, int *s) { std::sort(x, x + a); std::sort(y, y + b); std::vector<int> ord(t); iota(ord.begin(), ord.end(), 0); std::sort(ord.begin(), ord.end(), [&](int i, int j) { return std::tie(w[i], s[i]) < std::tie(w[j], s[j]); }); auto check = [&](int k) { std::priority_queue<int> pq; int j = 0; for (int i = 0; i < a; ++i) { while (j < t && w[ord[j]] < x[i]) { pq.push(s[ord[j++]]); } int could = k; while (pq.size() && could) { pq.pop(); --could; } } while (j < t) { pq.push(s[ord[j++]]); } for (int i = b - 1; i >= 0; --i) { int could = k; while (pq.size() && pq.top() < y[i] && could) { pq.pop(); --could; } } return !pq.size(); }; int l = 1, r = t, res = -1; while (l <= r) { int m = (l + r) / 2; if (check(m)) { res = m; r = m - 1; } else { l = m + 1; } } return res; }
#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...