Submission #971020

#TimeUsernameProblemLanguageResultExecution timeMemory
971020androRobots (IOI13_robots)C++14
53 / 100
183 ms23480 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X, X + A); sort(Y, Y + B); for(int i = 0; i < T; i++) { if(W[i] >= X[A - 1] && S[i] >= Y[B - 1]) { return - 1; } } vector<pair<int,int>> omg; for(int i = 0; i < T; i++) { omg.push_back({W[i], S[i]}); } sort(omg.begin(), omg.end()); int l = 1, r = 1e6, ans = - 1; while(l <= r) { int mid = (l + r) / 2; int pok = A - 1; int R = 0; vector<pair<int,int>> ostalo; for(int i = omg.size() - 1; i >= 0; i--) { //cout << pok << " " << omg[i].first << " " << omg[i].second << "\n"; if(pok < 0) { for(int j = i; j >= 0; j--) { ostalo.push_back({omg[j].second, omg[j].first}); } break; } if(X[pok] > omg[i].first) { R += 1; if(R >= mid) { R = 0; pok -= 1; } } else { ostalo.push_back({omg[i].second, omg[i].first}); } } //return 1; sort(ostalo.begin(), ostalo.end()); for(auto it : ostalo) { //cout << it.second << " " << it.first << "\n"; } //return 1; pok = B - 1; R = 0; int ok = 0; for(int i = ostalo.size() - 1; i >= 0; i--) { if(pok < 0) { ok = 1; break; } if(Y[pok] > ostalo[i].first) { R += 1; if(R >= mid) { R = 0; pok -= 1; } } else { ok = 1; break; } } ok ^= 1; if(ok) { r = mid - 1; ans = mid; } else { l = mid + 1; } //cout << l << " " << r << "\n"; //return - 1; } return ans; } /* int main() { int A = 3; int B = 2; int T = 10; int X[3] = {6, 2, 9}; int Y[2] = {4, 7}; int W[10] = {4, 8, 2, 7, 1, 5, 3, 8, 7, 10}; int S[10] = {6, 5, 3, 9, 8, 1, 3, 7, 6, 5}; cout << putaway(A, B, T, X, Y, W, S); int A = 2; int B = 1; int T = 3; int X[2] = {2, 5}; int Y[1] = {2}; int W[3] = {3, 5, 2}; int S[3] = {1, 3, 2}; cout << putaway(A, B, T, X, Y, W, S); }*/

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:47:18: warning: variable 'it' set but not used [-Wunused-but-set-variable]
   47 |         for(auto it : ostalo) {
      |                  ^~
#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...