# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
67566 | thebes | 로봇 (IOI13_robots) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int MN = 1e6+6;
pair<int,int> wts[MN];
priority_queue<int> q;
int N, M, T, i;
vector<int> a, b;
bool check(int m){
while(q.size()) q.pop();
int i=0, j = 0;
for(i=0,j=0;i<N;i++){
while(j<T&&wts[j].first<a[i]) q.push(wts[j++].second);
for(int k=0;k<m&&q.size();k++) q.pop();
}
for(;j<T;j++) q.push(wts[j].second);
for(int k=b.size()-1;k>=0;k--){
for(int i=0;i<m&&q.size()&&q.top()<b[k];i++) q.pop();
}
return q.empty();
}
int putaway(int A,int B,int t,int *X,int *Y,int *W,int *S){
N = A, M = B, T = t;
for(int i=0;i<T;i++)
wts[i] = {W[i],S[i]};
for(int i=0;i<N;i++)
a.push_back(X[i]);
for(int i=0;i<M;i++)
b.push_back(Y[i]);
sort(a.begin(),a.end());
sort(b.begin(),b.end());
sort(wts,wts+T,[](pii i,pii j){return i.first<j.first;});
int lo = 1, hi = T+1;
while(lo<hi){
int m = lo+hi>>1;
if(check(m)) hi=m;
else lo=m+1;
}
return(hi==T+1)?-1:hi;
}