제출 #965513

#제출 시각아이디문제언어결과실행 시간메모리
965513ThegeekKnight16로봇 (IOI13_robots)C++17
76 / 100
3086 ms34528 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; bool Test(int x, int A, int B, int T, int *X, int *Y, const vector<pair<int, int>> &Toy) { if ((long long)x*(A+B) < T) return 0; vector<int> sweep; //id sweep.reserve(max(A, B)+T); int idT = 0, idA = 0; while (idT < T && idA < A) { if (X[idA] <= Toy[idT].first) sweep.push_back(-1), idA++; else sweep.push_back(idT++); } while (idT < T) sweep.push_back(idT++); while (idA < A) sweep.push_back(-1), idA++; multiset<int> remain; for (auto id : sweep) { if (id == -1) { int remov = x; while (remov > 0 && !remain.empty()) remain.erase(prev(remain.end())), --remov; } else remain.insert(Toy[id].second); } sweep.clear(); //now type auto it = remain.begin(); int idB = 0; while (it != remain.end() && idB < B) { if (Y[idB] <= *it) sweep.push_back(-1), idB++; else sweep.push_back(1), it++; } if (it != remain.end()) return 0; while (idB < B) sweep.push_back(-1), idB++; int cnt = 0; for (auto type : sweep) { if (type == -1) cnt = max(0, cnt-x); else cnt++; } return (cnt == 0); } int putaway(int A, int B, int T, int X[], int Y[], int _W[], int _S[]) { vector<pair<int, int>> Toy(T); for (int i = 0; i < T; i++) Toy[i] = make_pair(_W[i], _S[i]); sort(X, X+A); sort(Y, Y+B); for (int i = 0; i < T; i++) if (Toy[i].first >= X[A-1] && Toy[i].second >= Y[B-1]) return -1; sort(Toy.begin(), Toy.end()); int ini = 1, fim = T; while (ini < fim) { int m = (ini + fim) >> 1; if (Test(m, A, B, T, X, Y, Toy)) fim = m; else ini = m+1; } return fim; }
#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...