Cpp easy soltn using priority queue


#1

int Solution::nchoc(int A, vector &B) {
priority_queue pq(B.begin(),B.end());
long long int temp,ans=0;
while(A!=0){
ans+=pq.top();
temp=pq.top();
pq.pop();
pq.push(floor(temp/2));
A–;
}
return ans%1000000007;
}