Submission #94353

#TimeUsernameProblemLanguageResultExecution timeMemory
94353fjzzq2002Robots (IOI13_robots)C++14
100 / 100
2290 ms63832 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second typedef pair<int,int> pii; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { vector<int> x,y; for(int i=0;i<A;++i) x.pb(X[i]); for(int i=0;i<B;++i) y.pb(Y[i]); sort(x.begin(),x.end()); sort(y.begin(),y.end()); multiset<pii> a,b; for(int i=0;i<T;++i) { int p=x.end()-upper_bound(x.begin(), x.end(),W[i]), q=y.end()-upper_bound(y.begin(), y.end(),S[i]); if(p==0&&q==0) return -1; a.insert(pii(p,q)); b.insert(pii(q,p)); } int cn=0; while(a.size()) { ++cn; for(int i=1;i<=A;++i) { auto g=a.lower_bound(pii(i,-233)); if(g==a.end()) break; pii x=*g; a.erase(g); b.erase(b.find(pii(x.se,x.fi))); } for(int i=1;i<=B;++i) { auto g=b.lower_bound(pii(i,-233)); if(g==b.end()) break; pii x=*g; b.erase(g); a.erase(a.find(pii(x.se,x.fi))); } } return cn; }
#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...