Submission #31156

#TimeUsernameProblemLanguageResultExecution timeMemory
31156pasa3232Robots (IOI13_robots)C++14
100 / 100
2526 ms26900 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; typedef pair<int, int> pp; struct C{ int x, y; bool operator<(const C &r)const{ return r.x>x; } }data[1000010]; int a, b, n, A[50010], B[50010]; priority_queue<pp> q; priority_queue<pp, vector<pp>, greater<pp> > q1; int putaway (int A1, int B1, int T, int X[], int Y[], int W[], int S[]){ // freopen("input.txt", "r", stdin); a=A1, b=B1, n=T; for(int i=0; i<a; i++) A[i]=X[i]; for(int i=0; i<b; i++) B[i]=Y[i]; for(int i=0; i<n; i++) data[i].x=W[i], data[i].y=S[i]; sort(data, data+n); sort(A, A+a); sort(B, B+b); int s=0, e=n+1; while(s!=e){ int t=(s+e)/2, inx=0; for(int i=0; i<a; i++){ while(inx<n&&data[inx].x<A[i]) q.push(make_pair(data[inx].y, data[inx].x)), inx++; for(int j=0; j<t; j++){ if(q.size()) q.pop(); else break; } } while(q.size()) q1.push(q.top()), q.pop(); for(int i=inx; i<n; i++) q1.push(make_pair(data[i].y, data[i].x)); for(int i=0; i<b; i++){ int cnt=0; while(q1.size()&&cnt<t&&q1.top().first<B[i]){ q1.pop(); cnt++; } } if(q1.size()>0) s=t+1; else e=t; while(q.size()) q.pop(); while(q1.size()) q1.pop(); } if(s==n+1) return -1; else return s; }
#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...