Submission #545549

#TimeUsernameProblemLanguageResultExecution timeMemory
545549timreizinRobots (IOI13_robots)C++17
100 / 100
2308 ms21964 KiB
#include "robots.h" #include <vector> #include <algorithm> #include <map> #include <iostream> 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) help2.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 = 1, 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...