●문제
●입출력
사용 알고리즘 : Stack
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds)
{
vector<int> answer;
vector<int> stkDay;
for (int i = 0; i < progresses.size(); i++)
{
int leftDay = (100 - progresses[i] + speeds[i] - 1) / speeds[i];
stkDay.push_back(leftDay);
}
int current = stkDay[0];
int count = 1;
for (int i = 1; i < stkDay.size(); i++)
{
//한번에 배포해주는 경우 계산
if (stkDay[i] <= current)
{
count++;
}
else
{
answer.push_back(count);
current = stkDay[i];
count = 1;
}
}
answer.push_back(count);
return answer;
}
레벨 : 2
점수 : 1
'C++ 프로그래머스 다이어리 > Stack,Queue' 카테고리의 다른 글
프로그래머스(C++) - 괄호 회전하기 (0) | 2025.10.14 |
---|---|
프로그래머스(C++) - 주식가격 (0) | 2025.10.08 |
프로그래머스(C++) - 프로세스 (0) | 2025.10.08 |
Algorithm - Stack, Queue (0) | 2025.08.07 |
프로그래머스(C++) - 짝지어 제거하기 (0) | 2025.08.02 |