Submission #544981

#TimeUsernameProblemLanguageResultExecution timeMemory
544981cig32Robots (IOI13_robots)C++17
100 / 100
1915 ms30620 KiB
#include "robots.h" #include <algorithm> #include <vector> #include <queue> bool special(std::pair<int, int> x, std::pair<int, int> y) { return x.second < y.second; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { std::sort(X, X + A); std::sort(Y, Y + B); int lb = 1, rb = T + 1; std::pair<int, int> toys[T]; for(int i=0; i<T; i++) { toys[i] = {W[i], S[i]}; } std::sort(toys, toys + T); while(lb < rb) { int mid = (lb + rb) >> 1; int prog = -1; std::priority_queue<std::pair<int, int> > pq; bool done[T]; for(int i=0; i<T; i++) done[i] = 0; for(int i=0; i<A; i++) { while(prog + 1 < T && toys[prog + 1].first < X[i]) { pq.push({toys[prog + 1].second, prog + 1}); prog++; } for(int j=0; j<mid; j++) { if(pq.empty()) break; done[pq.top().second] = 1; pq.pop(); } } std::vector<std::pair<int, int> > rem; for(int i=0; i<T; i++) { if(!done[i]) rem.push_back(toys[i]); } sort(rem.begin(), rem.end(), special); prog = -1; while(pq.size()) pq.pop(); int kek = 0; int cnt = 0; for(int i=0; i<B; i++) { while(prog + 1 < rem.size() && rem[prog + 1].second < Y[i]) { cnt++; prog++; } for(int j=0; j<mid; j++) { if(!cnt) break; kek++; cnt--; } } for(int i=0; i<T; i++) kek += done[i]; if(kek == T) rb = mid; else lb = mid + 1; } return (lb == T + 1 ? -1 : lb); }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |       while(prog + 1 < rem.size() && rem[prog + 1].second < Y[i]) {
      |             ~~~~~~~~~^~~~~~~~~~~~
#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...