Submission #956231

#TimeUsernameProblemLanguageResultExecution timeMemory
956231ZeroCoolRobots (IOI13_robots)C++14
100 / 100
1371 ms30684 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; const int M = 1e5 + 10; #define pb push_back int n,a,b; int _W[N], _S[N]; int _X[N]; int _Y[N]; pair<int,int> _A[N]; bool ok(int mid){ int p = 0; priority_queue<int> pq; for(int i = 0;i<a;i++){ while(p < n && _A[p].first < _X[i]){ pq.push(_A[p].second); p++; } int k = mid; while(pq.size() && k--){ pq.pop(); } } while(p < n)pq.push(_A[p++].second); vector<int> v; while(pq.size()){ v.pb(pq.top()); pq.pop(); } for(int i =0 ;i<b;i++){ int k = mid; while(v.size() && v.back() < _Y[i] && k--){ v.pop_back(); } } return v.empty(); } int putaway(int A, int B, int T, int x[], int y[], int w[], int s[]) { a = A; b = B; n = T; sort(x, x+a); sort(y, y + b); 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<n;i++){ _A[i] = {w[i], s[i]}; } sort(_A, _A+n); int lo = 1; int hi = n; // int ans = -1; while(lo <= hi){ int mid = (lo + hi) / 2; if(ok(mid)){ hi = mid -1; // ans = mid; }else lo = mid + 1; } if(hi == n)return -1; return hi + 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...