Submission #669810

#TimeUsernameProblemLanguageResultExecution timeMemory
6698101binRobots (IOI13_robots)C++17
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; #define all(v) v.begin(), v.end() const int NMAX = 1e6 + 5; int A, B, T, X[NMAX], Y[NMAX], W[NMAX], S[NMAX]; int go(int A, int B, int T, int X[], int Y[], int W[], int S[], int m){ vector<pair<int, int>> v; priority_queue<int> pq; for(int i = 0; i < T; i++) v.emplace_back(W[i], S[i]); sort(all(v)); int ix = 0; for(int i = 0; i < A; i++){ while(ix < v.size() && v[ix].first < X[i]) pq.emplace(v[ix++].second); for(int j = 0; j < m; j++){ if(pq.size()) pq.pop(); else break; } } while(ix < v.size()) pq.emplace(v[ix++].second); for(int i = B - 1; i >= 0; i--){ for(int j = 0; j < m; j++){ if(pq.size() && Y[i] > pq.top()) pq.pop(); else break; } } return pq.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){ int l = 1, r = T + 1, m; sort(X, X + A); sort(Y, Y + B); while(l < r){ m = (l + r) / 2; cout << l << ' ' << r << '\n'; if(go(A, B, T, X, Y, W, S, m)) r = m; else l = m + 1; } return l == T + 1 ? -1 : l; } /* int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> A >> B >> T; for(int i = 0; i < A; i++) cin >> X[i]; for(int i = 0; i < B; i++) cin >> Y[i]; for(int i = 0; i < T; i++) cin >> W[i] >> S[i]; cout << putaway(A, B, T, X, Y, W, S); return 0; }*/

Compilation message (stderr)

robots.cpp: In function 'int go(int, int, int, int*, int*, int*, int*, int)':
robots.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         while(ix < v.size() && v[ix].first < X[i]) pq.emplace(v[ix++].second);
      |               ~~~^~~~~~~~~~
robots.cpp:23:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     while(ix < v.size()) pq.emplace(v[ix++].second);
      |           ~~~^~~~~~~~~~
#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...