Submission #993414

#TimeUsernameProblemLanguageResultExecution timeMemory
993414Muaath_5Robots (IOI13_robots)C++17
28 / 100
3070 ms40308 KiB
#pragma GCC optimize("Ofast,O3,unroll-loops") #pragma GCC target("avx2,avx,sse3,sse4") #include "robots.h" #include <bits/stdc++.h> using namespace std; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X, X+A); sort(Y, Y+B); vector<pair<int, int>> v; for (int i = 0; i < T; i++) v.push_back({W[i], S[i]}); sort(v.begin(), v.end()); for (int i = 0; i < T; i++) { W[i] = v[i].first, S[i] = v[i].second; if (A && B) if (W[i] >= X[A-1] && S[i] >= Y[B-1]) return -1; if (A && !B) if (W[i] >= X[A-1]) return -1; if (!A && B) if (S[i] >= Y[B-1]) return -1; } if (T == 2 && A+B == 2) { if (A==2) { if (*max_element(X, X+A) <= *max_element(W, W+T)) return -1; if (X[0] > W[0] && X[1] > W[1]) return 1; return 2; } if (B==2) { if (*max_element(Y, Y+B) <= *max_element(S, S+T)) return -1; if (Y[0] > S[0] && Y[1] > S[1]) return 1; return 2; } if ((X[0] > W[0] && Y[0] > S[1]) || (X[0] > W[1] && Y[0] > S[0])) return 1; if ((X[0] > W[0] && X[0] > W[1]) || (Y[0] > S[0] && Y[0] > S[1])) return 2; return -1; } if (B == 0) { multiset<int> s; for (int i = 0; i < T; i++) s.insert(W[i]); int sol = 0; while (s.size()) { for (int i = A-1; s.size() && i >= 0; i--) { auto it = s.lower_bound(X[i]); if (it == s.begin()) break; it--; s.erase(it); } sol++; } return sol; } int l = 1, r = T; while (l < r) { const int mid = (l+r)/2; int idx = 0; priority_queue<int> pq; for (int i = 0; idx < T && i < A; i++) { while (idx < T && W[idx] < X[i]) { pq.push(W[idx]); idx++; } for (int j = 0; pq.size() && j < mid; j++) pq.pop(); } bool ok = true; for (int i = B; i >= 0; i--) { for (int j = 0; j < mid; j++) { if (!pq.size()) break; if (pq.top() >= Y[i]) { ok = false; break; } } if (!pq.size()) break; if (!ok) break; } if (ok) l = mid; else r = 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...