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 <bits/stdc++.h>
#include "robots.h"
#define vc vector
using namespace std;
int putaway(int A,int B,int T, int X[], int Y[],int W[],int S[]){
int l=1, r=T+1;
vc<int> ind(T);for(int i=0;i<T;++i) ind[i]=i;
sort(ind.begin(), ind.end(), [&](int a, int b){return W[a]<W[b];});
sort(X, X+A);
function<bool (int)> check=[&](int k){
map<int, int> prosti;
for(int i=0;i<B;++i) prosti[Y[i]]+=k;
int j=A-1;
for(int i=T-1;i>=0;--i){
while(j>=0 and X[j]>W[ind[i]]) prosti[INT_MAX]+=k, --j;
auto poi=prosti.upper_bound(S[ind[i]]);
if(poi==prosti.end()) return false;
if(--poi->second ==0) prosti.erase(poi);
}
return true;
};
if(check(T)){
while(l<r){
int mid=(l+r)/2;
if(check(mid)) r=mid;
else l=mid+1;
}
return l;
}
else return -1;
}
# | 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... |