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 <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <iostream>
using namespace std;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
vector<int> weak_robots;
vector<int> small_robots;
for (int i = 0; i < A; i++){
weak_robots.push_back(X[i]);
}
for (int i = 0; i < B; i++){
small_robots.push_back(Y[i]);
}
sort(weak_robots.begin(), weak_robots.end());
sort(small_robots.begin(), small_robots.end());
for (int i = 0; i < T; i++){
if (weak_robots.size() >= 1 && small_robots.size() >= 1){
if (weak_robots[weak_robots.size() - 1] <= W[i] && small_robots[small_robots.size() - 1] <= S[i]){
return -1;
}
}
if (weak_robots.size() == 0){
if (small_robots[small_robots.size() - 1] <= S[i]){
return -1;
}
}
if (small_robots.size() == 0){
if (weak_robots[weak_robots.size() - 1] <= W[i]){
return -1;
}
}
}
int put_away = 0;
int time_taken = 0;
vector<bool> removed (T, false);
while (put_away != T){
time_taken++;
//cout << put_away << endl;
for (int i = 0; i < A; i++){
int largest_size = 0;
int largest_index = -1;
for (int j = 0; j < T; j++){
if (!removed[j] && W[j] < weak_robots[i] && S[j] > largest_size){
largest_index = j;
largest_size = S[j];
}
}
if (largest_index != -1){
removed[largest_index] = true;
put_away++;
}
}
for (int i = 0; i < B; i++){
int largest_weight = 0;
int largest_index = -1;
for (int j = 0; j < T; j++){
if (!removed[j] && S[j] < small_robots[i] && W[j] > largest_weight){
largest_index = j;
largest_weight = W[j];
}
}
if (largest_index != -1){
removed[largest_index] = true;
put_away++;
}
}
}
return time_taken;
}
# | 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... |