Submission #1160917

#TimeUsernameProblemLanguageResultExecution timeMemory
1160917SmuggingSpunRobots (IOI13_robots)C++20
100 / 100
1425 ms16852 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; const int lim = 1e6 + 5; bitset<lim>vis; int putaway(int A, int B, int n, int X[], int Y[], int W[], int S[]){ sort(X, X + A); sort(Y, Y + B); vector<int>pw(n), ps(n); for(int i = 0; i < n; i++){ pw[i] = ps[i] = i; } sort(pw.begin(), pw.end(), [&] (int i, int j){ return W[i] < W[j]; }); sort(ps.begin(), ps.end(), [&] (int i, int j){ return S[i] < S[j]; }); int low = 1, high = n, ans = -1; while(low <= high){ int mid = (low + high) >> 1; vis.reset(); priority_queue<pair<int, int>>pq; for(int i = 0, j = 0; i < A; i++){ while(j < n && W[pw[j]] < X[i]){ pq.emplace(S[pw[j]], pw[j]); j++; } for(int _ = 0; _ < mid && !pq.empty(); _++, pq.pop()){ vis.set(pq.top().second); } } while(!pq.empty()){ pq.pop(); } for(int i = 0, j = 0; i < B; i++){ while(j < n && S[ps[j]] < Y[i]){ if(!vis.test(ps[j])){ pq.emplace(W[ps[j]], ps[j]); } j++; } for(int _ = 0; _ < mid && !pq.empty(); _++, pq.pop()){ vis.set(pq.top().second); } } if(vis.count() == n){ high = (ans = mid) - 1; } else{ low = mid + 1; } } return ans; }
#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...