이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include<bits/stdc++.h>
using namespace std;
int n, m, t;
vector<int> weak, small;
vector<pair<int, int>> toy;
bool check(int x) {
priority_queue<pair<int, int>> pq;
queue<pair<int, int>> q;
for (auto c : toy) {
pq.push(c);
}
for (int i : weak) {
while(!q.empty()) {
pq.push(q.front());
q.pop();
}
int co = x;
while(!pq.empty() && co > 0) {
auto [s, w] = pq.top();
pq.pop();
if (w < i) {
co--;
} else {
q.push({s, w});
}
}
}
for (int i : small) {
int co = x;
while(!pq.empty() && co > 0) {
auto [s, w] = pq.top();
pq.pop();
if (s < i) {
co--;
} else {
return 0;
}
}
}
if (pq.empty()) {
return 1;
} else {
return 0;
}
}
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 < t; i++) {
toy.push_back({S[i], W[i]});
}
for (int i = 0; i < n; i++) {
weak.push_back(X[i]);
}
for (int i = 0; i < m; i++) {
small.push_back(Y[i]);
}
int l = 1, r = T;
sort(toy.rbegin(), toy.rend());
sort(weak.begin(), weak.end());
sort(small.rbegin(), small.rend());
while(l < r) {
int m = (l+r)/2;
if (check(m)) {
r = m;
} else {
l = m+1;
}
}
if (check(l)) {
return l;
} 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... |