Easy C++ solution using max heap


#1

int Solution::nchoc(int A, vector &B) {
priority_queue pq;
for(int i=0;i<B.size();i++)
pq.push(B[i]);

long long sum=0;
while(A){
    int num=pq.top();
    sum += num;
    pq.pop();
    pq.push(floor(num/2));
    A--;
}
return sum%(1000000007);

}