Submission #182380

#TimeUsernameProblemLanguageResultExecution timeMemory
182380arman_ferdousRobots (IOI13_robots)C++17
0 / 100
3 ms524 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; struct ds{ multiset<pair<int,int>> st; void insert(int x, int y) { st.insert({x, y}); } void remove(int x, int y) { st.erase({x, y}); } pair<int,int> find(int x) { auto it = st.lower_bound({x, -1}); if(it == st.begin()) return {-1, -1}; it--; return {it->first, it->second}; } }one, two; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X, X + A); sort(Y, Y + B); for(int i = 0; i < T; i++) { one.insert(W[i], S[i]); two.insert(S[i], W[i]); } int ans = 0, sz = T; while(sz) { int cnt = 0; for(int i = A - 1; i >= 0 && sz; i--) { auto got = one.find(X[i]); if(got.first == -1) break; cnt++, sz--; one.remove(got.first, got.second); two.remove(got.second, got.first); } for(int i = B - 1; i >= 0 && sz; i--) { auto got = two.find(Y[i]); if(got.first == -1) break; cnt++, sz--; two.remove(got.first, got.second); one.remove(got.second, got.first); } if(cnt == 0) { ans = -1; break; } ans++; } return ans; }
#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...