Java solution with priorityQueue


#1
public class Solution {
public int nchoc(int A, ArrayList<Integer> B) {
    long sum=0;
    PriorityQueue<Long> q=new PriorityQueue<Long>(Collections.reverseOrder());
    for(int i=0;i<B.size();i++)
    {
        q.add((long)B.get(i));
    }
    while(A>0)
    {
        long m=q.poll();
        sum+=m;
        q.add(m/2);
        A--;
    }
    return (int)(sum%(Math.pow(10,9) +7));
}

}