[프로그래머스 2레벨] 디펜스 게임 (C++)
#include #include #include using namespace std;int solution(int n, int k, vector enemy) { int answer = enemy.size(); //모든 라운드 버팀 상정 priority_queue, greater> pq; for(int i=0; i k) { n -= pq.top(); //병사 사용 pq.pop(); } if(0 > n) //병력 소진 { answer = i; break; } } return answer;} 우선순위 큐를 활용한 문제이다...
프로그래머스/2레벨
2025. 3. 17. 04:02