Submission #93083

#TimeUsernameProblemLanguageResultExecution timeMemory
93083Bodo171Robots (IOI13_robots)C++14
100 / 100
1791 ms19264 KiB
#include "robots.h" #include <fstream> #include <vector> #include <queue> #include <algorithm> #include <iostream> using namespace std; const int nmax=1000*1000+5; pair<int,int> v[nmax]; int a[nmax],b[nmax]; priority_queue<int> pq; int A,B,i,n,j; bool check(int val) { while(!pq.empty()) pq.pop(); int p=1; for(i=1;i<=A;i++) { while(p<=n&&v[p].first<a[i]) { pq.push(v[p].second); p++; } for(j=1;j<=val&&(!pq.empty());j++) pq.pop(); } while(p<=n) { pq.push(v[p].second); p++; } for(i=B;i>=1;i--) { for(j=1;j<=val&&(!pq.empty())&&pq.top()<b[i];j++) pq.pop(); } return (pq.empty()); } int putaway(int Aa, int Bb, int T, int X[], int Y[], int W[], int S[]) { n=T; for(i=1;i<=T;i++) { v[i].first=W[i-1]; v[i].second=S[i-1]; } sort(v+1,v+n+1); A=Aa;B=Bb; for(i=1;i<=A;i++) a[i]=X[i-1]; sort(a+1,a+A+1); for(i=1;i<=B;i++) b[i]=Y[i-1]; sort(b+1,b+B+1); int timp=(1<<20)-1; if(!check(timp)) return -1; for(int p=19;p>=0;p--) if(check(timp-(1<<p))) timp-=(1<<p); return timp; }
#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...