이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
const int mxN = (int)5e4+10;
int n, m, t, x[mxN], y[mxN];
struct Toy{ int w, s; };
vector<Toy> toy;
bool chk(int tim){
priority_queue<int> pq;
while(sz(pq))pq.pop();
for(int i = 0, j = 0; i < n; i++){
while(j<t and toy[j].w<x[i])
pq.push(toy[j++].s);
int xd = tim;
while(xd-- and sz(pq)) pq.pop();
if(i==n-1) while(j<t) pq.push(toy[j++].s);
}
for(int i = m-1; i >= 0; i--){
int xd = tim;
while(xd-- and sz(pq)){
if(pq.top()>=y[i]) return 0;
pq.pop();
}
}
return !sz(pq);
}
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 < n; i++) x[i] = X[i];
for(int i = 0; i < m; i++) y[i] = Y[i];
for(int i = 0; i < t; i++) toy.pb({W[i],S[i]});
sort(x,x+n), sort(y,y+m);
sort(begin(toy),end(toy),[&](Toy a, Toy b){return a.w<b.w;});
int l = 0, r = t;
while(l<r){
int mid = (l+r)/2;
if(chk(mid)) r=mid;
else l=mid+1;
}
if(chk(l)) return l;
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... |