This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (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... |