이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()
const int MX=1e6+1e5;
int a, b, t;
int x[MX], y[MX], w[MX], s[MX];
int SA[MX];
bool possible(int T) {
int n=0;
priority_queue<int> pq;
RE(i,a) {
while(n != t && w[SA[n]] < x[i]) {
pq.push(s[SA[n++]]);
}
RE(j,T) {
if(pq.empty()) break;
pq.pop();
}
}
while(n != t) {
pq.push(s[SA[n++]]);
}
RE(i,b) {
RE(j,T) {
if(pq.empty()) return 1;
if(pq.top() >= y[i]) return 0;
pq.pop();
}
}
return pq.empty();
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
a=A; b=B; t=T;
RE(i,A) x[i]=X[i];
RE(i,B) y[i]=Y[i];
RE(i,T) w[i]=W[i], s[i]=S[i];
RE(i,t) SA[i]=i;
sort(SA,SA+t, [](int i, int j) {
return w[i]<w[j];
});
sort(x,x+a);
sort(y,y+b,greater<int>());
int lb=0, ub=T;
while(lb != ub) {
int mid=(lb+ub)/2;
if(possible(mid)) ub=mid;
else lb=mid+1;
}
if(!possible(lb)) lb=-1;
return lb;
}
# | 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... |