이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> toys;//(weight,size)
int a,b,t;
int* x;
int* y;
bool check(int s){
int pos=0;
priority_queue<int> q;//with size
for(int i=0;i<a;i++){
while(pos<t && toys[pos].first<x[i]){
q.push(toys[pos].second);
pos++;
}
int cnt=0;
while(!q.empty() && cnt<s){
q.pop();//it goes to weak robot i
cnt++;
}
}
//put the remaining to small robots in the same way
while(pos<t){
q.push(toys[pos].second);
pos++;
}
for(int i=b-1;i>=0 && !q.empty();i--){
int cnt=0;
if(q.top()>=y[i]) return false;
while(!q.empty() && cnt<s){
q.pop();
cnt++;
}
}
return q.empty()?true:false;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
sort(X,X+A);
sort(Y,Y+B);
for(int i=0;i<T;i++){
toys.push_back({W[i],S[i]});
}
sort(toys.begin(),toys.end());
x=X;
y=Y;
a=A;
b=B;
t=T;
//binary search
int k=T;
for(int bima=T;bima>0;bima/=2){
while(k-bima>=0&&check(k-bima)) k-=bima;
}
return check(k)?k:-1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |