제출 #7037

#제출 시각아이디문제언어결과실행 시간메모리
7037gs13068로봇 (IOI13_robots)C++98
100 / 100
508 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,k,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; 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); } l=1;r=T; while(l<r) { mid=(l+r)/2; for(i=0;i<T;i++)V[i]=0; j=0; for(i=B-1;i>=0;i--) { j+=mid; if(j>2e9)j=2e9; for(k=E[i].size()-1;k>=0&&j>0;k--) { V[E[i][k]]=1; 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...