import java.util.*;
class Solution {
public int solution(int[] scoville, int K) {
int answer = 0;
PriorityQueue<Integer> q = new PriorityQueue();
for(int sco: scoville){
q.add(sco);
}
while(q.peek() < K){
int lessSpicy = q.poll();
if(!q.isEmpty()){
int secondLessSpicy = q.poll();
q.add(lessSpicy+secondLessSpicy*2);
answer++;
}else{return -1;}
}
return answer;
}
}