This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]);
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |