Submission #116940

#TimeUsernameProblemLanguageResultExecution timeMemory
116940dragonslayeritRobots (IOI13_robots)C++14
90 / 100
3024 ms14072 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[]) { int low=0,high=T+1; while(high-low>1){ int mid=(low+high)/2; objects_cnt=0; for(int i=0;i<A;i++){ objects[objects_cnt++]={X[i]-1,INF,mid}; } for(int i=0;i<B;i++){ objects[objects_cnt++]={INF,Y[i]-1,mid}; } for(int i=0;i<T;i++){ objects[objects_cnt++]={W[i],S[i],-1}; } std::sort(objects,objects+A+B+T); std::reverse(objects,objects+A+B+T); std::map<int,int> active; bool bad=false; for(int i=0;i<A+B+T;i++){ auto obj=objects[i]; 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 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...