Submission #7026

#TimeUsernameProblemLanguageResultExecution timeMemory
7026gs13068Robots (IOI13_robots)C++98
100 / 100
1884 ms22552 KiB
#include "robots.h" #include<algorithm> #include<set> #include<vector> int V[1000000]; std::pair<int,int> D[1000000]; int R[50000]; std::vector<int> E[50000]; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { int i,j,l,r,mid; for(i=0;i<T;i++) { D[i].first=W[i]+1; D[i].second=S[i]+1; } std::sort(X,X+A); std::sort(Y,Y+B); std::sort(D,D+T); for(i=0;i<T;i++)if((!A||D[i].first>X[A-1])&&(!B||D[i].second>Y[B-1]))return -1; l=1;r=T; while(l<r) { mid=(l+r)/2; for(i=0;i<T;i++)V[i]=0; for(i=0;i<B;i++)E[i].clear(); for(i=0;i<T;i++) { j=std::lower_bound(Y,Y+B,D[i].second)-Y; if(j<B)E[j].push_back(i); } j=0; for(i=B-1;i>=0;i--) { j+=mid; if(j>2e9)j=2e9; while(j>0&&E[i].size()) { V[E[i][E[i].size()-1]]=1; E[i].pop_back(); j--; } } for(i=0;i<A;i++)R[i]=0; j=0; for(i=0;i<T;i++)if(!V[i]) { while(j<A&&(X[j]<D[i].first||R[j]==mid))j++; if(j<A) { V[i]=1; R[j]++; } else break; } if(i==T)r=mid; else l=mid+1; } return r; }
#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...