diff --git "a/Programmers/\353\215\224_\353\247\265\352\262\214.cpp" "b/Programmers/\353\215\224_\353\247\265\352\262\214.cpp" new file mode 100644 index 0000000..4e9afd2 --- /dev/null +++ "b/Programmers/\353\215\224_\353\247\265\352\262\214.cpp" @@ -0,0 +1,28 @@ +#include +#include +#include + +using namespace std; + +int solution(vector scoville, int K) { + priority_queue, greater> pq; + + for (int s : scoville) { + pq.push(s); + } + + int mixCount = 0; + + while (pq.size() >= 2 && pq.top() < K) { + int first = pq.top(); + pq.pop(); + int second = pq.top(); + pq.pop(); + + int newScoville = first + (second * 2); + pq.push(newScoville); + mixCount++; + } + + return (pq.top() >= K) ? mixCount : -1; +} \ No newline at end of file