CPP solution using pq


#1

int Solution::nchoc(int A, vector &B) {
priority_queuepq;
for(int i=0;i<B.size();i++){
pq.push(B[i]);
}
int mod=1000000007;
int ans=0;
for(int i=0;i<A;i++){
int d=pq.top();
ans=(ans%mod)+(d%mod);
ans=ans%mod;
pq.pop();
pq.push(d/2);
}
return ans;
}