이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
struct S{
int w, s;
bool operator <(const S &a)const{
return w<a.w;
}
};
vector<S> v;
vector<int> x, y;
priority_queue<int> pq;
bool chk(int k){
while(!pq.empty()) pq.pop();
int j=0, t;
for(int i=0; i<v.size(); i++){
while(j<x.size() && x[j]<=v[i].w){
t = k;
while(t-- && !pq.empty()) pq.pop();
j++;
}
pq.push(v[i].s);
}
while(j<x.size()){
t = k;
while(t-- && !pq.empty()) pq.pop();
j++;
}
for(int i=y.size()-1; i>=0; i--){
t = k;
while(t-- && !pq.empty()){
if(pq.top()>=y[i]) return false;
pq.pop();
}
}
return pq.empty();
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
for(int i=0; i<A; i++) x.push_back(X[i]);
for(int i=0; i<B; i++) y.push_back(Y[i]);
for(int i=0; i<T; i++) v.push_back({W[i], S[i]});
sort(x.begin(), x.end()); sort(y.begin(), y.end()); sort(v.begin(), v.end());
int s = 1, e = 1000000, m;
while(s<e){
m = (s+e)/2;
if(chk(m)) e = m;
else s = m+1;
}
if(chk(s)) return s;
return -1;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'bool chk(int)':
robots.cpp:23:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size(); i++){
~^~~~~~~~~
robots.cpp:24:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(j<x.size() && x[j]<=v[i].w){
~^~~~~~~~~
robots.cpp:31:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(j<x.size()){
~^~~~~~~~~
# | 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... |