제출 #17219

#제출 시각아이디문제언어결과실행 시간메모리
17219murat로봇 (IOI13_robots)C++98
100 / 100
2140 ms25744 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; #define st first #define nd second #define mp make_pair const int N = 1e6 + 5; int a1, a2, n, ww[N], ss[N]; pair< int , int > a[N]; bool ctr(int x) { priority_queue< int > q; int j = 0; for(int i = 0; i < a1; i++) { while(j < n && a[j].st < ww[i]) { q.push(a[j++].nd); } int tt = x; while(q.size() && tt--) { q.pop(); } } while(j < n) { q.push(a[j++].nd); } for(int i = a2 - 1; i >= 0; i--) { int tt = x; while(q.size() && tt--) { if(q.top() >= ss[i]) return false; q.pop(); } } return q.size() == 0; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { n = T; a1 = A; a2 = B; for(int i = 0; i < T; i++) { a[i] = mp(W[i], S[i]); } sort(a, a+T); sort(X, X+A); sort(Y, Y+B); for(int i = 0; i < A; i++) { ww[i] = X[i]; } for(int i = 0; i < B; i++) { ss[i] = Y[i]; } int bas = 0, son = T + 1; while(bas < son) { int orta = bas + son >> 1; if(ctr(orta)) son = orta; else bas = orta + 1; } return bas == T + 1 ? -1 : bas; }
#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...