제출 #123747

#제출 시각아이디문제언어결과실행 시간메모리
123747turbat로봇 (IOI13_robots)C++14
100 / 100
2009 ms25288 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; int a, b, t, *x, *y, *w, *s, cnt; priority_queue <int> se, ss; pair <int, int> p[1000005]; vector <int> vc; bool can(int k){ se = ss; int j = 0; for (int i = 0;i < a;i++){ while (j < t && p[j].first < x[i]) se.push(s[p[j++].second]); cnt = k; while (cnt-- && !se.empty()) se.pop(); } for (;j < t;j++) se.push(s[p[j].second]); vc.clear(); while (!se.empty()){ vc.push_back(se.top()); se.pop(); } reverse(vc.begin(), vc.end()); j = 0; cnt = k; for (auto it : vc){ while (j < b && (!cnt || it >= y[j])){ j++; cnt = k; } if (j == b) return 0; cnt--; } return 1; } 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); for (int i = 0;i < t;i++){ if (w[i] >= x[a - 1] && s[i] >= y[b - 1]) return -1; p[i].first = w[i]; p[i].second = i; } sort(p, p + t); int l = 1, r = t, mid; while (l != r){ mid = (l + r) / 2; if (can(mid)) r = mid; else l = mid + 1; } return l; }
#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...