이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define ln "\n"
using namespace std;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
vector<ll> weak(A), small(B);
vector<pair<ll, ll>> toy(T);
for (ll i=0; i<A; i++){
weak[i]=X[i];
}
for (ll i=0; i<B; i++){
small[i]=Y[i];
}
for (ll i=0; i<T; i++){
toy[i] = {W[i], S[i]};
}
sort(weak.rbegin(), weak.rend());
sort(small.rbegin(), small.rend());
sort(toy.rbegin(), toy.rend());
vector<ll> slot_small;
multiset<pair<ll, ll>> cand;
multiset<ll> usd;
auto check = [&](ll x){
slot_small.clear(); cand.clear();
ll l=0, free_robot=0;
for (ll i=0; i<T; i++){
while (l<A and weak[l]>toy[i].ff) {
l++;
free_robot+=x;
}
cand.insert({toy[i].ss, i});
if (free_robot>0) free_robot--;
else{
slot_small.push_back((*cand.begin()).ss);
cand.erase(cand.begin());
}
}
sort(slot_small.rbegin(), slot_small.rend(), [&](ll op1, ll op2){
return toy[op1].ss<toy[op2].ss;
});
l=0; usd.clear();
for (ll i=0; i<(ll)(slot_small.size()); i++){
while (l<B and small[l]>toy[slot_small[i]].ss){
usd.insert(0);
l++;
}
if (usd.empty()) return 0;
ll val = *usd.begin();
usd.erase(usd.begin());
usd.insert(val+1);
}
if (x>=*usd.rbegin()) return 1;
return 0;
};
ll l=0, r=T;
while (l+1<r){
ll mid = (l+r)/2;
if (check(mid)) r=mid;
else l=mid;
}
if (check(r)) return r;
else return -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... |