Submission #1035818

#TimeUsernameProblemLanguageResultExecution timeMemory
1035818andrei_iorgulescuRobots (IOI13_robots)C++14
100 / 100
2189 ms32808 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; vector<int> x,y; vector<pair<int,int>> robots; bool cmp(pair<int,int> A, pair<int,int> B) { return A.second < B.second; } bool pot(int k) { vector<bool> luat(robots.size()); priority_queue<pair<int,int>> pq; int i1 = 0; for (int i = 0; i < x.size(); i++) { while (i1 < robots.size() and robots[i1].first < x[i]) { pq.push({robots[i1].second,i1}); i1++; } int ct = k; while (!pq.empty() and ct > 0) { ct--; pair<int,int> idk = pq.top(); pq.pop(); luat[idk.second] = true; } } while (!pq.empty()) pq.pop(); vector<pair<int,int>> r; for (int i = 0; i < robots.size(); i++) if (!luat[i]) r.push_back(robots[i]); sort(r.begin(),r.end(),cmp); i1 = 0; int lt = 0; for (int i = 0; i < y.size(); i++) { while (i1 < r.size() and r[i1].second < y[i]) { pq.push({r[i1].first,i1}); i1++; } int ct = k; while (!pq.empty() and ct > 0) { ct--; lt++; pair<int,int> idk = pq.top(); pq.pop(); } } if (lt == r.size()) return true; return false; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { for (int i = 0; i < A; i++) x.push_back(X[i]); for (int i = 0; i < B; i++) y.push_back(Y[i]); sort(x.begin(),x.end()); sort(y.begin(),y.end()); for (int i = 0; i < T; i++) robots.push_back({W[i],S[i]}); sort(robots.begin(),robots.end()); for (auto it : robots) if ((A == 0 or it.first >= x[A - 1]) and (B == 0 or it.second >= y[B - 1])) return -1; int st = 0,pas = 1 << 19; while (pas != 0) { if (!pot(st + pas)) st += pas; pas /= 2; } return st + 1; }

Compilation message (stderr)

robots.cpp: In function 'bool pot(int)':
robots.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < x.size(); i++)
      |                     ~~^~~~~~~~~~
robots.cpp:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         while (i1 < robots.size() and robots[i1].first < x[i])
      |                ~~~^~~~~~~~~~~~~~~
robots.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i = 0; i < robots.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
robots.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i = 0; i < y.size(); i++)
      |                     ~~^~~~~~~~~~
robots.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         while (i1 < r.size() and r[i1].second < y[i])
      |                ~~~^~~~~~~~~~
robots.cpp:56:27: warning: variable 'idk' set but not used [-Wunused-but-set-variable]
   56 |             pair<int,int> idk = pq.top();
      |                           ^~~
robots.cpp:60:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     if (lt == r.size())
      |         ~~~^~~~~~~~~~~
#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...