Submission #1185694

#TimeUsernameProblemLanguageResultExecution timeMemory
1185694harvsftwRobots (IOI13_robots)C++20
100 / 100
1594 ms57784 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; #define F(i, n) for(int i = 0; i < (n); i++) int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { using state = pair<int, int>; multiset<state> by_weight, by_size; F(i, T) { by_weight.emplace(W[i], S[i]); by_size.emplace(S[i], W[i]); } multiset<state> robots; F(i, A) { robots.emplace(X[i], 0); } F(i, B) { robots.emplace(Y[i], 1); } int t = 0; while(!robots.empty() && !by_weight.empty()) { vector<state> remove; for(auto [capability, type] : robots) { if(type == 0) { auto it = by_weight.lower_bound({capability, 0}); if(it != by_weight.begin()) { --it; by_weight.extract(it); by_size.extract({it->second, it->first}); } else { remove.emplace_back(capability, type); } } else { auto it = by_size.lower_bound({capability, 0}); if(it != by_size.begin()) { --it; by_size.extract(it); by_weight.extract({it->second, it->first}); } else { remove.emplace_back(capability, type); } } } t++; for(auto rem : remove) { robots.erase(rem); } } //cout << by_weight.size() << " remaining" << endl; if(by_weight.empty()) { return t; } else { return -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...