제출 #545364

#제출 시각아이디문제언어결과실행 시간메모리
545364benson1029로봇 (IOI13_robots)C++14
100 / 100
1576 ms24636 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; int a,b,t; int x[50005], y[50005]; pair<int,int> w[1000005]; priority_queue<int> st; stack<int> stk; bool check(int mid) { while(!stk.empty()) stk.pop(); int ptr=0; for(int i=0; i<a; i++) { while(ptr < t && w[ptr].first < x[i]) { st.push(w[ptr].second); ptr++; } for(int j=0; j<mid; j++) { if(st.empty()) break; st.pop(); } } while(ptr < t) { st.push(w[ptr].second); ptr++; } while(!st.empty()) { stk.push(st.top()); st.pop(); } for(int i=0; i<b; i++) { for(int j=0; j<mid; j++) { if(stk.empty()) break; if(stk.top() >= y[i]) break; stk.pop(); } } if(stk.empty()) return true; return false; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { a = A; b = B; t = T; for(int i=0; i<a; i++) x[i] = X[i]; for(int i=0; i<b; i++) y[i] = Y[i]; sort(x, x+a); sort(y, y+b); for(int i=0; i<t; i++) { w[i].first = W[i]; w[i].second = S[i]; if(w[i].first >= x[a-1] && w[i].second >= y[b-1]) { return -1; } } sort(w, w+t); int l,r,mid; l = 1; r = t; while(l<r) { mid = (l+r)/2; if(check(mid)) r = mid; else l = mid+1; } 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...