Submission #116939

#TimeUsernameProblemLanguageResultExecution timeMemory
116939dragonslayeritRobots (IOI13_robots)C++14
90 / 100
3045 ms34248 KiB
#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 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...