이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "robots.h"
struct Elem{
int val;
bool operator < (const Elem &aux) const{
return val > aux.val;
}
};
std::vector <int> Z;
std::priority_queue <Elem> pq;
int f(int lim, int A, int B, int T, int X[], int Y[], std::pair <int, int> V[]){
Z.clear();
while(!pq.empty()) pq.pop();
int pos = 0;
for(int i = -1; i < A; i++){
while(pos < T && (i == A - 1 || V[pos].first >= X[i + 1]))
pq.push({V[pos++].second});
while(pq.size() > 1LL * (i + 1) * lim){
Z.push_back(pq.top().val);
pq.pop();
}
}
std::sort(Z.begin(), Z.end());
std::reverse(Z.begin(), Z.end());
pos = 0;
for(int i = -1; i < B; i++){
while(pos < Z.size() && (i == B - 1 || Z[pos] >= Y[i + 1]))
pos++;
if(pos > 1LL * (i + 1) * lim) return 0;
}
return 1;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){
std::sort(X, X + A), std::reverse(X, X + A);
std::sort(Y, Y + B), std::reverse(Y, Y + B);
std::pair <int, int> V[T];
for(int i = 0; i < T; i++)
V[i] = {W[i], S[i]};
std::sort(V, V + T);
std::reverse(V, V + T);
if(!f(T, A, B, T, X, Y, V)) return -1;
int l = 1, r = T;
while(r - l > 1){
int m = (l + r) / 2;
if(f(m, A, B, T, X, Y, V)) r = m;
else l = m + 1;
}
if(f(l, A, B, T, X, Y, V)) return l;
return r;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'int f(int, int, int, int, int*, int*, std::pair<int, int>*)':
robots.cpp:21:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(pq.size() > 1LL * (i + 1) * lim){
~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
robots.cpp:31:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(pos < Z.size() && (i == B - 1 || Z[pos] >= Y[i + 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... |