Submission #1088692

#TimeUsernameProblemLanguageResultExecution timeMemory
1088692VMaksimoski008Robots (IOI13_robots)C++17
76 / 100
3024 ms18408 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,bmi,bmi2,lzcnt,popcnt") int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { vector<array<int, 3> > v; for(int i=0; i<T; i++) v.push_back({ W[i], S[i], 0 }); sort(X, X + A); sort(Y, Y + B); int l=1, r=T, ans=-1; while(l <= r) { int mid = (l + r) / 2; bool ok = 1; for(int i=0; i<T; i++) v[i][2] = 0; sort(v.begin(), v.end()); priority_queue<pii> pq; int j = 0; for(int i=0; i<A; i++) { while(j < T && v[j][0] < X[i]) pq.push({ v[j][1], j }), j++; for(int k=0; k<mid&&!pq.empty(); k++) { v[pq.top().second][2] = 1; pq.pop(); } } vector<int> vec; sort(v.begin(), v.end(), [&](array<int, 3> &a, array<int, 3> &b) { return a[1] < b[1]; }); j = 0; for(int i=0; i<B; i++) { while(j < T && v[j][1] < Y[i]) { if(v[j][2] == 0) vec.push_back(j); j++; } for(int k=0; k<mid&&!vec.empty(); k++) { v[vec.back()][2] = 1; vec.pop_back(); } } for(int i=0; i<T&&ok; i++) if(v[i][2] == 0) ok = 0; if(ok) ans = mid, r = mid - 1; else l = 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...