이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <map>
#include <vector>
#include <algorithm>
#include <array>
const int INF=2e9+7;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
int low=0,high=T+1;
while(high-low>1){
int mid=(low+high)/2;
std::vector<std::array<int,3> > objects;
for(int i=0;i<A;i++){
objects.push_back({X[i]-1,INF,mid});
}
for(int i=0;i<B;i++){
objects.push_back({INF,Y[i]-1,mid});
}
for(int i=0;i<T;i++){
objects.push_back({W[i],S[i],-1});
}
std::sort(objects.begin(),objects.end());
std::reverse(objects.begin(),objects.end());
std::map<int,int> active;
bool bad=false;
for(auto obj:objects){
if(obj[2]>0){
active[obj[1]]+=obj[2];
}else{
auto it=active.lower_bound(obj[1]);
if(it==active.end()){
bad=true;
break;
}else{
//printf("(%d,%d) matches with (?,%d)\n",obj[0],obj[1],it->first);
if(--it->second==0){
active.erase(it);
}
}
}
}
if(bad){
low=mid;
}else{
high=mid;
}
}
return (high<=T)?high:-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... |