もっと辛い


#include <string>
#include <vector>
#include <queue>
using namespace std;

int solution(vector<int> scoville, int K) {
    int answer = 0;
    priority_queue<int,vector<int>,greater<>> cook;
    for(int i=0;i<scoville.size();i++){
        cook.push(scoville[i]);
    }// 우선순위큐에 대입
    
    while(cook.top()<K){
        if(cook.size()<=1){
            answer=-1;
            break;
        }
        int s=cook.top();
        cook.pop();
        int s2=cook.top();
        cook.pop();
        cook.push(s+s2*2);
        answer++;
    }
    
    return answer;
}