제출 #1013176

#제출 시각아이디문제언어결과실행 시간메모리
1013176amirhoseinfar1385로봇 (IOI13_robots)C++17
14 / 100
1184 ms29360 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; const int maxn=100000+10,maxm=1000000+10; vector<pair<int,int>>allb; vector<int>x,y; int n,m,t; int dp[maxm],p; bool check(int mid){ priority_queue<pair<int,int>>st; int l=0; for(int i=0;i<(int)allb.size();i++){ while(l<(int)x.size()&&x[l]<allb[i].first){ for(int j=0;j<(int)st.size()&&j<mid;j++){ st.pop(); } l++; } st.push(make_pair(allb[i].second,i)); } while(l<(int)x.size()){ for(int j=0;0<(int)st.size()&&j<mid;j++){ st.pop(); } l++; } vector<int>ham; while((int)st.size()>0){ ham.push_back(st.top().first); st.pop(); } reverse(ham.begin(),ham.end()); for(int j=0;j<(int)y.size();j++){ for(int h=0;h<mid&&(int)ham.size()>0&&(ham.back())<=y[j];h++){ ham.pop_back(); } } if((int)ham.size()==0){ return 1; } return 0; } int solve(){ int low=0,high=t+2,mid; while(high-low>1){ mid=(high+low-1)>>1; if(check(mid)==0){ low=mid+1; }else{ high=mid+1; } } if(low>t){ low=-1; } return low; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { n=A; m=B; t=T; for(int i=0;i<n;i++){ X[i]--; x.push_back(X[i]); } for(int i=0;i<m;i++){ Y[i]--; y.push_back(Y[i]); } for(int i=0;i<t;i++){ allb.push_back(make_pair(W[i],S[i])); } sort(x.begin(),x.end()); sort(y.begin(),y.end()); sort(allb.begin(),allb.end()); return solve(); }
#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...