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 fi first
#define se second
typedef pair <int ,int > ii;
const int N=1e6+5;
const int M=5e4+5;
int x[M],y[M];
int ca[M],cb[M];
int n,m,s;
ii w[N];
bool check(int mid)
{
for (int i=1;i<=n;i++)
{
ca[i]=mid;
}
multiset <ii> st;
for (int i=1;i<=m;i++)
{
st.insert({y[i],mid});
}
int ida=n;
for (int i=1;i<=s;i++)
{
auto pp=st.upper_bound({w[i].se,1e9+5});
if (pp!=st.end())
{
if ((*pp).se==1)
{
st.erase(pp);
}
else
{
ii gg={(*pp).fi,(*pp).se-1};
st.erase(pp);
st.insert(gg);
}
}
else
{
if (ca[ida]==0)
{
ida--;
}
if (ida==0||x[ida]<=w[i].fi)
{
return false;
}
ca[ida]--;
}
}
return true;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
int ans=-1;
int left=1;
int right=T;
n=A;
m=B;
s=T;
for (int i=1;i<=A;i++)
{
x[i]=X[i-1];
}
sort (x+1,x+n+1);
for (int i=1;i<=B;i++)
{
y[i]=Y[i-1];
}
sort (y+1,y+m+1);
for (int i=1;i<=T;i++)
{
w[i].fi=W[i-1];
w[i].se=S[i-1];
}
sort (w+1,w+s+1,greater <ii> ());
while (left<=right)
{
int mid=(left+right)/2;
if (check(mid)==true)
{
ans=mid;
right=mid-1;
}
else left=mid+1;
}
return ans;
}
# | 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... |