Submission #256434

#TimeUsernameProblemLanguageResultExecution timeMemory
256434A02Robots (IOI13_robots)C++14
0 / 100
3068 ms8664 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<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 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...