이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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<long long> weak_robots;
vector<long long> 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[weak_robots.size() - 1] <= W[i] && small_robots[small_robots.size() - 1] <= S[i]){
return -1;
}
}
long long put_away = 0;
long long 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++){
long long largest_size = 0;
long long 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++){
long long largest_weight = 0;
long long 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... |