Submission #598708

#TimeUsernameProblemLanguageResultExecution timeMemory
598708Bench0310Robots (IOI13_robots)C++17
100 / 100
1567 ms24376 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; typedef long long ll; int putaway(int A,int B,int n,int limX[],int limY[],int X[],int Y[]) { sort(limX,limX+A); sort(limY,limY+B); vector<array<int,2>> v(n); for(int i=0;i<n;i++) v[i]={X[i],Y[i]}; sort(v.begin(),v.end()); int l=0,r=n+1; while(l<r-1) { int cnt=(l+r)/2; priority_queue<int> q; int idx=0; for(int i=0;i<A;i++) { while(idx<n&&v[idx][0]<limX[i]) q.push(v[idx++][1]); for(int j=0;j<cnt&&!q.empty();j++) q.pop(); } while(idx<n) q.push(v[idx++][1]); for(int i=B-1;i>=0;i--) { int c=cnt; while(c>0&&!q.empty()&&q.top()<limY[i]) { q.pop(); c--; } } if(q.empty()) r=cnt; else l=cnt; } return (r<=n?r:-1); }
#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...