Submission #116650

#TimeUsernameProblemLanguageResultExecution timeMemory
116650roseanne_pcyRobots (IOI13_robots)C++14
100 / 100
1724 ms29424 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxn = 5e4+5; const int maxt = 1e6+5; int n, m, t; int x[maxn], y[maxn]; int w[maxt], s[maxt]; vector< ii > vec; priority_queue<int> pq; bool works(int lim) { while(!pq.empty()) pq.pop(); vector<int> rem; if(n == 0) { for(int i = 0; i< t; i++) rem.pb(vec[i].Y); } else { int pt = 0; for(int i = 0; i< n; i++) { while(pt< t && vec[pt].X< x[i]) { pq.push(vec[pt].Y); pt++; } int times = lim; while(!pq.empty() && times--) pq.pop(); } while(!pq.empty()) { rem.pb(pq.top()); pq.pop(); } while(pt< t) rem.pb(vec[pt++].Y); } sort(rem.begin(), rem.end()); int k = rem.size(); int pt = 0, cnt = 0; for(int i = 0; i< m; i++) { while(pt< k && rem[pt]< y[i]) pt++, cnt++; cnt = max(cnt-lim, 0); } while(pt< k) pt++, cnt++; return cnt == 0; } int putaway(int A, int B, int T, int _X[], int _Y[], int _W[], int _S[]) { for(int i = 0; i< A; i++) x[i] = _X[i]; for(int i = 0; i< B; i++) y[i] = _Y[i]; for(int i = 0; i< T; i++) { w[i] = _W[i]; s[i] = _S[i]; } n = A; m = B; t = T; for(int i = 0; i< t; i++) vec.pb(ii(w[i], s[i])); sort(vec.begin(), vec.end()); sort(x, x+n); sort(y, y+m); int lo = 1, hi = T; while(lo< hi) { int mid = (lo+hi)/2; if(works(mid)) hi = mid; else lo = mid+1; } if(works(lo)) return lo; return -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...