Submission #982592

#TimeUsernameProblemLanguageResultExecution timeMemory
982592kwongwengRobots (IOI13_robots)C++17
100 / 100
2982 ms35728 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef vector<vector<ll>> vll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define pb push_back #define ms memset #define fi first #define se second /* Solution is binary search */ 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(i,0,T){ if (W[i]>=X[A-1] && S[i]>=Y[B-1]) return -1; } int l = 0, r = T+1; vii w(T+A); FOR(i,0,T) w[i] = {W[i],S[i]}; FOR(i,T,T+A) w[i] = {X[i-T],0}; sort(w.begin(), w.end()); while (r-l>1){ int mid = (l+r)/2; priority_queue<int> p; FOR(i,0,T+A){ if (w[i].se > 0){ p.push(w[i].se); continue; } int cnt = 0; while (!p.empty() && cnt < mid){ p.pop(); cnt++; } } vii rem; while (!p.empty()){ rem.pb({p.top(),1}); p.pop(); } FOR(i,0,B) rem.pb({Y[i],0}); sort(rem.begin(), rem.end()); priority_queue<int> q; FOR(i,0,rem.size()){ if (rem[i].se>0){ q.push(rem[i].fi); continue; } int cnt = 0; while (!q.empty() && cnt < mid){ q.pop(); cnt++; } } if (q.empty()){ r=mid; }else{ l=mid; } } return r; }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:10:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
   51 |         FOR(i,0,rem.size()){
      |             ~~~~~~~~~~~~~~             
robots.cpp:51:9: note: in expansion of macro 'FOR'
   51 |         FOR(i,0,rem.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...