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 rep(i,n) for(int i=0; i<(n); i++)
#define all(x) x.begin(),x.end()
using ll=long long;
const ll INF=1LL<<60;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
vector<int> x(A);
rep(i,A){
x[i]=X[i];
}
sort(all(x));
vector<int> y(B);
rep(i,B){
y[i]=Y[i];
}
vector<pair<int,int>> toy(T);
rep(i,T){
toy[i]={W[i],S[i]};
}
sort(all(toy));
int ng=0,ok=T+1;
while(ok-ng>1){
int mid=(ok+ng)/2;
multiset<int> size;
int cnt=0;
rep(i,A){
while(cnt<T&&toy[cnt].first<x[i]){
size.insert(toy[cnt].second);
cnt++;
}
rep(j,mid){
if(size.empty())break;
size.erase(size.find(*size.rbegin()));
}
}
while(cnt<T){
size.insert(toy[cnt].second);
cnt++;
}
rep(i,B){
rep(j,mid){
if(size.empty())break;
if(*size.begin()>=y[i])break;
size.erase(size.find(*size.begin()));
}
}
if(size.empty())ok=mid;
else ng=mid;
}
if(ok==T+1)return -1;
return ok;
}
# | 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... |