문제 링크입니다: https://school.programmers.co.kr/learn/courses/30/lessons/389479
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
문제 지문에서 주어진 대로 구현하면 되는 문제였습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <vector> | |
#include <queue> | |
using namespace std; | |
int solution(vector<int> players, int m, int k) { | |
int answer = 0; | |
queue<int> q; | |
for (int t = 0; t < 24; t++) | |
{ | |
while (!q.empty() && q.front() <= t) | |
{ | |
q.pop(); | |
} | |
int required = players[t] / m; | |
if (required > q.size()) | |
{ | |
int expansion = required - q.size(); | |
answer += expansion; | |
for (int i = 0; i < expansion; i++) | |
{ | |
q.push(t + k); | |
} | |
} | |
} | |
return answer; | |
} |

개발환경: Programmers IDE
지적, 조언, 질문 환영합니다! 질문 남겨주세요~
반응형
'알고리즘 > programmers' 카테고리의 다른 글
[Programmers] 봉인된 주문 (0) | 2025.02.18 |
---|---|
[Programmers] 완전범죄 (0) | 2025.02.17 |
[Programmers] 홀짝트리 (10) | 2025.02.14 |
[Programmers] 지게차와 크레인 (0) | 2025.02.13 |
[Programmers] 비밀 코드 해독 (0) | 2025.02.11 |