제출 #1029985

#제출 시각아이디문제언어결과실행 시간메모리
1029985tolbi로봇 (IOI13_robots)C++17
100 / 100
1355 ms24948 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { int l = 1, r = T; int maa = 0; int mab = 0; for (int i = 0; i < A; i++) { maa=max(maa,X[i]); } for (int i = 0; i < B; i++) { mab=max(mab,Y[i]); } for (int i = 0; i < T; i++){ if (maa<=W[i] && mab<=S[i]) return -1; } array<int,2> events[A+T]; for (int i = 0; i < A; ++i) { events[i]={X[i],-1}; } for (int i = 0; i < T; ++i){ events[A+i]={W[i],S[i]}; } sort(events,events+A+T); sort(Y,Y+B);reverse(Y,Y+B); while (l<r){ int mid = l+(r-l)/2; priority_queue<int> pq; for (int i = 0; i < A+T; i++){ if (events[i][1]==-1){ int kal = mid; while (pq.size() && kal--) pq.pop(); } else { pq.push(events[i][1]); } } for (int i = 0; i < B; i++){ int kal = mid; while (pq.size() && kal--){ if (pq.top()>=Y[i]) break; pq.pop(); } } if (pq.size()>0){ l=mid+1; } else r=mid; } return l; }
#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...