Submission #945687

#TimeUsernameProblemLanguageResultExecution timeMemory
945687vjudge1Robots (IOI13_robots)C++17
100 / 100
1352 ms27756 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define sz(a) (int)a.size() #define s second #define f first using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; bool can(int m, int a, int b, int t, int x[], int y[], vector<pii> s) { int p = 0; priority_queue<int> h; for (int i = 0; i < a; i++) { while (p < sz(s) && s[p].f < x[i]) { h.push(s[p].s); p++; } int k = m; while (sz(h) && k--) h.pop(); } while (p < sz(s)) h.push(s[p++].s); vector<int> hh; while (sz(h)) { hh.push_back(h.top()); h.pop(); } for (int i = 0; i < b; i++) { int k = m; while (sz(hh) && hh.back() < y[i] && k--) { hh.pop_back(); } } return hh.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { vector<pii> s; for (int i = 0; i < T; i++) s.push_back({W[i], S[i]}); sort(s.begin(), s.end()); sort(X, X + A); sort(Y, Y + B); int l = 1, r = T; while (l <= r) { int m = (l + r) / 2; if (can(m, A, B, T, X, Y, s)) r = m - 1; else l = m + 1; } if (r == T) return -1; return r + 1; }
#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...