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;
/*
int solve(int a, int b, int pos_A, int pos_B){
for
}
*/
int visitados[1000000];
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
memset(visitados,0,sizeof(visitados));
int botactive=A+B;
bool isweak=true;
int pos=0;
int cont=0;
int time=0;
bool noBs=false;
while(botactive>0 && cont<T){
//cout<<cont<<" cont botactive:"<<botactive<<endl;
//cout<<pos<<" pos, isweak:"<<isweak<<endl;
if((isweak==true || noBs==true)&& A>0){
int currentW=-1;
int currentpos=-1;
//cout<<X[pos]<<" XPOS"<<endl;
if(X[pos]!=-1){
for(int i=0;i<T;i++){
//cout<<visitados[i]<<" i:"<<i<<endl;
if(visitados[i]==0 && W[i]<X[pos]){
if(W[i]>currentW){
currentW=W[i];
currentpos=i;
}else if(W[i]==currentW){
if(S[i]>S[currentpos]){
currentW=W[i];
currentpos=i;
}
}
}
}
}else{
pos++;
continue;
}
//cout<<currentpos<<" CURRENTPOS"<<endl;
if(currentpos!=-1){
visitados[currentpos]=1;
pos++;
cont++;
}else{
//cout<<X[pos]<<" REMOVE XPOS"<<endl;
X[pos]=-1;
botactive--;
pos++;
}
if(pos>=A || botactive<=0 || cont>=T){
isweak=false;
pos=0;
if(noBs==true || botactive<=0 || cont>=T){
time++;
}
}
}else{
if(B==0){
isweak=true;
noBs=true;
time++;
pos=0;
continue;
}
int currentS=-1;
int currentpos=-1;
//cout<<S[pos]<<" spos"<<endl;
//cout<<Y[pos]<<" YPOS"<<endl;
if(Y[pos]!=-1){
for(int i=0;i<T;i++){
if(visitados[i]==0 && S[i]<Y[pos]){
if(S[i]>currentS){
currentS=S[i];
currentpos=i;
}else if(S[i]==currentS){
if(W[i]>W[currentpos]){
currentS=S[i];
currentpos=i;
}
}
}
}
}else{
pos++;
continue;
}
//cout<<currentpos<<" CURRENTPOS"<<endl;
if(currentpos!=-1){
visitados[currentpos]=1;
pos++;
cont++;
}else{
Y[pos]=-1;
pos++;
botactive--;
}
//cout<<pos<<endl;
if(pos>=B || botactive<=0 || cont>=T){
//cout<<pos<<" "<<botactive<<" "<<cont<<" POS BOT CONT"<<endl;
isweak=true;
pos=0;
time++;
}
}
}
//cout<<cont<<endl;
if(cont<T){
return -1;
}else{
return time;
}
}
# | 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... |