#include using namespace std; using ll = long long; ll powll (ll a,ll n){ if(60> n; multiset h; for(ll i = 0;i> v; h.insert(v); } auto solve = [&](ll x)-> bool { multiset hp(h.begin(),h.end()); while(hp.size()){ x--; if(x<0)return false; ll atk = powll(2,x); ll M = *hp.rbegin(); hp.erase(prev(hp.end())); ll nhp = M - atk; if(nhp > 0){ hp.insert(nhp); } } return true; }; ll ok = 250000; ll ng = 0; while(ok - ng > 1){ ll mid = midpoint(ng,ok); if(solve(mid))ok = mid; else ng = mid; } cout << ok << endl; }