Submission #676364

#TimeUsernameProblemLanguageResultExecution timeMemory
676364groshiRobots (IOI13_robots)C++17
100 / 100
1469 ms24716 KiB
#include<iostream> #include<algorithm> #include<queue> #include"robots.h" using namespace std; int putaway(int A,int B,int T,int x[],int y[],int W[],int S[]) { vector<pair<int,int> > zabawki; for(int i=0;i<T;i++) zabawki.push_back({W[i],S[i]}); sort(zabawki.begin(),zabawki.end()); vector<int> X,Y; for(int i=0;i<A;i++) X.push_back(x[i]); for(int i=0;i<B;i++) Y.push_back(y[i]); sort(X.begin(),X.end()); sort(Y.begin(),Y.end()); int pocz=1,kon=T+1,sre,ostd=-1; while(pocz<kon) { sre=(pocz+kon)/2; int gdzie=0; priority_queue<int> kolejka; for(int i=0;i<A;i++) { while(gdzie<T && zabawki[gdzie].first<X[i]) kolejka.push(zabawki[gdzie].second),gdzie++; for(int j=0;j<sre;j++) if(!kolejka.empty()) kolejka.pop(); else break; } while(gdzie<T) kolejka.push(zabawki[gdzie].second),gdzie++; for(int i=B-1;i>=0;i--) { if(kolejka.empty()) break; if(Y[i]<=kolejka.top()) break; for(int j=0;j<sre;j++) if(!kolejka.empty()) kolejka.pop(); else break; } if(kolejka.empty()) { ostd=sre; kon=sre; } else pocz=sre+1; } return ostd; }
#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...