Submission #545541

#TimeUsernameProblemLanguageResultExecution timeMemory
545541timreizinRobots (IOI13_robots)C++17
0 / 100
1 ms300 KiB
#include "robots.h" #include <vector> #include <algorithm> #include <map> using namespace std; int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]) { vector<int> x(a), y(b); vector<pair<int, int>> ws(t); for (int i = 0; i < a; ++i) x[i] = X[i]; for (int i = 0; i < b; ++i) y[i] = Y[i]; for (int i = 0; i < t; ++i) ws[i] = {W[i], S[i]}; sort(ws.begin(), ws.end(), [](auto a, auto b){ return a.second > b.second; }); auto check = [&ws, &x, &y](int m) -> bool { multimap<int, int> help; for (int i : x) help.insert({i, m}); multimap<int, int> help2; for (int i : y) help.insert({i, m}); for (auto [w, s] : ws) { auto it = help.upper_bound(w); if (it == help.end()) { auto it = help2.upper_bound(s); if (it == help2.end()) return false; --it->second; if (it->second == 0) help2.erase(it); continue; } --it->second; if (it->second == 0) help.erase(it); } return true; }; if (!check(t)) return -1; int l = 0, r = t; while (l < r) { int m = (l + r) >> 1; if (check(m)) r = m; else l = m + 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...