이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
#define all( x ) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> ii;
vector<ii> v;
vector<int> w, s;
bool f( int n ) {
priority_queue<int> q;
int j = 0;
for(int i=0;i<w.size();i++) {
while( j < v.size() && v[j].fi < w[i] ) q.push( v[j].se ), j++;
int tr = n;
while( tr-- > 0 && !q.empty() ) q.pop();
}
while( j < v.size() ) q.push( v[j].se ), j++;
if( q.empty() ) return 1;
for(int i=s.size()-1;i>=0;i--) {
if( q.top() >= s[i] ) return 0;
int tr = n;
while( tr-- > 0 && !q.empty() ) q.pop();
if( q.empty() ) return 1;
}
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
for(int i=0;i<T;i++) v.pb( ii( W[i], S[i] ) );
sort( X, X+A );
sort( Y, Y+B );
for(int i=0;i<A;i++) w.pb( X[i] );
for(int i=0;i<B;i++) s.pb( Y[i] );
//binary search
int t = 0;
for(int k=19;k>=0;k--)
if( !f( t+(1<<k) ) ) t += 1<<k;
t++;
if( !f( t ) ) return -1;
return t;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'bool f(int)':
robots.cpp:18:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<w.size();i++) {
^
robots.cpp:19:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while( j < v.size() && v[j].fi < w[i] ) q.push( v[j].se ), j++;
^
robots.cpp:23:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while( j < v.size() ) q.push( v[j].se ), j++;
^
robots.cpp:31:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |