Submission #503011

#TimeUsernameProblemLanguageResultExecution timeMemory
503011kevinRobots (IOI13_robots)C++17
90 / 100
3068 ms34852 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define nl cout<<"\n" #define s second #define f first #define all(x) x.begin(), x.end() #define ca(v) for(auto i:v) cout<<i<<" "; bool solve(int m, vector<int> &X, vector<int> &Y, vector<pair<int, int>> T){ priority_queue<pair<int, int>> q; int r = 0; for(int x : X){ while(r < T.size() && T[r].f < x) {q.push({T[r+1].s, T[r+1].f}); r++;} int rem = m; while(rem && q.size()) { q.pop(); rem--; } } for(int i=r; i<T.size(); i++) q.push({T[i].s, T[i].f}); T.clear(); while(q.size()) { T.push_back(q.top()); q.pop(); } sort(all(T)); r = 0 ; for(int x:Y){ while(r < T.size() && T[r].f < x) {q.push({T[r+1].s, T[r+1].f}); r++;} int rem = m; while(rem && q.size()) { q.pop(); rem--; } } return r == T.size() && q.size() == 0; } int putaway(int A, int B, int N, int x[], int y[], int w[], int s[]){ vector<int> X, Y, W, 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]); for(int i=0; i<N; i++) W.push_back(w[i]); for(int i=0; i<N; i++) S.push_back(s[i]); sort(all(X)); sort(all(Y)); int ans = N+1; int l = 1; int r = N; vector<pair<int, int>> T; for(int i=0; i<N; i++) T.push_back({W[i], S[i]}); sort(all(T)); while(l <= r){ int m = (l + r) / 2; if(solve(m, X, Y, T)){ ans = m; r = m-1; } else l = m+1; } if(ans == N+1) return -1; return ans; }

Compilation message (stderr)

robots.cpp: In function 'bool solve(int, std::vector<int>&, std::vector<int>&, std::vector<std::pair<int, int> >)':
robots.cpp:17:17: 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(r < T.size() && T[r].f < x) {q.push({T[r+1].s, T[r+1].f}); r++;}
      |               ~~^~~~~~~~~~
robots.cpp:24: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]
   24 |     for(int i=r; i<T.size(); i++) q.push({T[i].s, T[i].f});
      |                  ~^~~~~~~~~
robots.cpp:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         while(r < T.size() && T[r].f < x) {q.push({T[r+1].s, T[r+1].f}); r++;}
      |               ~~^~~~~~~~~~
robots.cpp:37: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]
   37 |     return r == T.size() && q.size() == 0;
      |            ~~^~~~~~~~~~~
#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...