제출 #58071

#제출 시각아이디문제언어결과실행 시간메모리
58071naderjemel로봇 (IOI13_robots)C++14
90 / 100
3008 ms60652 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; bool td[1000005]; int tt[1000005]; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){ vector<pair<pair<int,int>,int> > w,s; for(int i=0;i<T;i++){ w.push_back(make_pair(make_pair(W[i],S[i]),i)); s.push_back(make_pair(make_pair(S[i],W[i]),i)); } sort(s.begin(),s.end()); sort(w.begin(),w.end()); sort(X,X+A); sort(Y,Y+B); int lo=1,hi=T; int rs=T+2; while(lo<=hi){memset(td,false,sizeof(td)); int mid=(lo+hi)>>1; int l=0; int done=0; priority_queue<pair<int,int> > pq; for(int i=0;i<A;i++){ pair<pair<int,int>,int> sc = {{X[i],0},0}; int idx=lower_bound(w.begin(),w.end(),sc)-w.begin(); for(int j=idx-1;j>=l;j--) pq.push(make_pair(w[j].first.second,w[j].second)); l=idx; int s=0; while(s<mid && !pq.empty()){ s++; int idx=pq.top().second; td[idx]=true; done++; pq.pop(); } } l=0; for(;!pq.empty();pq.pop()); for(int i=0;i<B;i++){ pair<pair<int,int>,int> sc = {{Y[i],0},0}; int idx=lower_bound(s.begin(),s.end(),sc)-s.begin(); for(int j=idx-1;j>=l;j--){ if(!td[s[j].second]){ pq.push(make_pair(s[j].first.second,s[j].second)); } } l=idx; int s=0; while(s<mid && !pq.empty()){ s++; int idx=pq.top().second; td[idx]=true; pq.pop(); done++; } } if(done==T){ rs=mid; hi=mid-1; } else{ lo=mid+1; } } if(rs==T+2) return -1; else return rs; }
#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...