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>
using namespace std;
#define ll long long
#define pb push_back
const int N=1000100;
const int R=100000;
int a,b,t;
vector<int>x;
vector<int>y;
vector<int>w;
vector<int>s;
vector<pair<int,int>> WS;
int itpass(int md, priority_queue<pair<int,int>>pq){
}
int binary(int mn, int md, int mx){
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>>pq;
vector<int>tosmall;
while(mx!=md){
//cout<<mn<<" "<<md<<" "<<mx<<endl;
int pos=0;
int cont=md;
bool posible=true;
int passrobs=0;
for(int i=0;i<t;i++){
//cout<<w[i]<<" "<<x[pos]<<" WI XPOS"<<endl;
//cout<<tosmall.size()<<endl;
if(pos>=a){
tosmall.pb(WS[i].second);
continue;
}
if(WS[i].first>=x[pos]){
if(passrobs==0){
tosmall.pb(WS[i].second);
}else{
pq.push({WS[i].first,passrobs});
}
continue;
}
cont--;
if(cont==0){
cont=md;
pos++;
}
}
if(posible==true){
mx=md;
md=(mn+mx)/2;
}else{
mn=md;
md=(mn+mx+1)/2;
}
}
return mx;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
a=A;
b=B;
t=T;
for(int i=0;i<t;i++){
w.pb(W[i]);
s.pb(S[i]);
WS.pb({w[i],s[i]});
}
for(int i=0;i<a;i++){
x.pb(X[i]);
}
for(int i=0;i<b;i++){
y.pb(Y[i]);
}
sort(WS.rbegin(),WS.rend());
sort(x.rbegin(),x.rend());
sort(y.rbegin(),y.rbegin());
int answer=binary(1,(t+3)/2,t+2);
if(answer>t) return -1;
return answer;
}
Compilation message (stderr)
robots.cpp: In function 'int itpass(int, std::priority_queue<std::pair<int, int> >)':
robots.cpp:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
19 | }
| ^
# | 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... |