제출 #769262

#제출 시각아이디문제언어결과실행 시간메모리
769262keta_tsimakuridze로봇 (IOI13_robots)C++14
28 / 100
1340 ms22912 KiB
#include "robots.h" #include<bits/stdc++.h> #define f first #define s second using namespace std; int putaway(int A, int B, int N, int X[], int Y[], int W[], int S[]) { vector<pair<int,int>> p(N); for(int i = 0; i < N; i++) { p[i] = {W[i], S[i]}; } sort(p.begin(), p.end()); // for(int i = 0; i < N; i++) cout << p[i].f << " " << p[i].s << "\n"; sort(X, X + A); sort(Y, Y + B); int l = 1, r = N, ans = N + 1; while(l <= r) { int mid = (l + r) / 2; priority_queue<int, vector<int>, less<int>> s; { int L = -1; for(int i = 0; i < A; i++) { while(L + 1 < N && p[L + 1].f < X[i]) ++L, s.push(p[L].s); for(int j = 1; j <= mid; j++) { if(!s.size()) break; s.pop(); } } while(L + 1 < N) s.push(p[L + 1].s),++L; for(int i = 0; i < B; i++) { for(int j = mid; j >= 1; j--) { if(!s.size() || s.top() >= Y[i]) break; s.pop(); } } } if(s.size()) l = mid + 1; else r = mid - 1, ans = mid; } if(ans > N ) ans = -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...