이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "robots.h"
using namespace std;
int putaway(int A,int B,int T,int X[],int Y[],int W[],int S[]){
sort(X, X + A);
reverse(X, X + A);
sort(Y, Y + B);
reverse(Y, Y + B);
vector<pair<int, int>> a(T);
bool f = 0;
for (int i = 0; i < T; i++){
a[i] = {W[i], S[i]};
if (a[i].first >= X[0] && a[i].second >= Y[0]) f = 1;
}
if (f) return -1;
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
int ini = 1, fin = T + 1;
while(ini < fin){
int m = (ini + fin) / 2;
int k = 0;
int tiempo = 0;
priority_queue<int> pq;
for (int i = 0; i < A; i++){
tiempo = 0;
while(k < T && tiempo < m && X[i] > a[k].first){
k++;
tiempo++;
}
if (k < T && tiempo < m && X[i] <= a[k].first){
pq.push(-a[k].second);
k++;
i--;
}
}
while(k < T){
pq.push(-a[k].second);
k++;
}
tiempo = 0;
bool cant = 0;
for (int i = 0; i < B && cant == 0; i++){
tiempo = 0;
while(tiempo < m && !pq.empty()){
int v = pq.top();
v = -v;
if (v < Y[i]) {
tiempo++;
pq.pop();
}else {
cant = 1;
break;
}
}
}
if (pq.empty() && cant == 0){
fin = m;
}else ini = m + 1;
}
return ini;
}
# | 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... |