제출 #116943

#제출 시각아이디문제언어결과실행 시간메모리
116943dragonslayerit로봇 (IOI13_robots)C++14
90 / 100
3039 ms24184 KiB
#include "robots.h" #include <map> #include <vector> #include <algorithm> #include <array> const int INF=2e9+7; std::array<int,3> objects[1100005]; int objects_cnt=0; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { for(int i=0;i<A;i++){ objects[objects_cnt++]={X[i]-1,INF,1}; } for(int i=0;i<B;i++){ objects[objects_cnt++]={INF,Y[i]-1,1}; } for(int i=0;i<T;i++){ objects[objects_cnt++]={W[i],S[i],0}; } std::sort(objects,objects+A+B+T); std::reverse(objects,objects+A+B+T); int low=0,high=T+1; while(high-low>1){ int mid=(low+high)/2; std::map<int,int> active; bool bad=false; for(int i=0;i<A+B+T;i++){ auto obj=objects[i]; if(obj[2]){ active[obj[1]]+=mid; }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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...