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>
#define st first
#define nd second
using namespace std;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
sort(X, X+A);
sort(Y, Y+B);
pair<int, int> tab[T];
for(int i=0; i<T; i++){
tab[i]={upper_bound(X, X+A, W[i])-X, upper_bound(Y, Y+B, S[i])-Y};
}
sort(tab, tab+T);
int l=1, r=T+1;
while(l<r){
int m=(l+r)/2;
bool b=1;
int j=A-1;
map<int, int> M;
for(int i=0; i<B; i++){
M[i]=m;
}
long long a=0;
for(int i=T-1; i>=0; i--){
while(j>=0 && j>=tab[i].st)j--, a+=m;
auto t=M.lower_bound(tab[i].nd);
if(t==M.end())a--;
else if(--(*t).nd==0)M.erase(t);
if(a<0){
b=0;
break;
}
}
if(b)r=m;
else l=m+1;
}
if(l==T+1)return -1;
return l;
}
# | 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... |