Submission #256438

#TimeUsernameProblemLanguageResultExecution timeMemory
256438A02Robots (IOI13_robots)C++14
76 / 100
3072 ms7416 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...