Submission #982891

#TimeUsernameProblemLanguageResultExecution timeMemory
982891hyakupRobots (IOI13_robots)C++17
76 / 100
3033 ms11112 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int inf = 2e9 + 10; vector<int> wbots, sbots; struct Toy{ int w, s; Toy( int w, int s ): w(w), s(s) {} bool operator < ( Toy t ){ return (( s == t.s ) ? w > t.w : s > t.s ); } }; vector<Toy> toys; bool check( int k ){ multiset<pair<int, int>> s; for( int x : wbots ) s.insert({ x - 1, k }); ll cont = 0; int i = 0; for( Toy cur : toys ){ for( i; i < sbots.size() && sbots[i] > cur.s; i++ ) cont += k; auto it = s.lower_bound({ cur.w, 0 }); if( it == s.end() ){ if( cont ){ cont--; continue; } return false; } auto [val, qtd] = *it; s.erase(it); if( qtd > 1 ) s.insert({ val, qtd - 1 }); } return true; } int bs(){ int t = toys.size(), b = wbots.size() + sbots.size(); int l = (t + b - 1)/b, r = t + 1; while( l < r ){ int mid = ( l + r )/2; if( check(mid) ) r = mid; else l = mid + 1; } return ( r == toys.size() + 1 ) ? -1 : r; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { for( int i = 0; i < A; i++ ) wbots.push_back(X[i]); for( int i = 0; i < B; i++ ) sbots.push_back(Y[i]); for( int i = 0; i < T; i++ ) toys.push_back( Toy( W[i], S[i] ) ); sort( sbots.rbegin(), sbots.rend() ); sort( toys.begin(), toys.end() ); return bs(); }

Compilation message (stderr)

robots.cpp: In function 'bool check(int)':
robots.cpp:20:10: warning: statement has no effect [-Wunused-value]
   20 |     for( i; i < sbots.size() && sbots[i] > cur.s; i++ ) cont += k;
      |          ^
robots.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for( i; i < sbots.size() && sbots[i] > cur.s; i++ ) cont += k;
      |             ~~^~~~~~~~~~~~~~
robots.cpp: In function 'int bs()':
robots.cpp:41:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Toy>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   return ( r == toys.size() + 1 ) ? -1 : r;
      |            ~~^~~~~~~~~~~~~~~~~~
#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...