vector<int> solution(vector<int> progresses, vector<int> speeds)
{
vector<int> answer;
map<int, int> tmp_map;
int size = progresses.size();
int* arr_days = new int[size] {0};
for (int i = 0; i < size; i++)
{
int count = 0;
for (int j = progresses[i]; j <= 100; j += speeds[i])
{
progresses[i] += speeds[i];
count++;
if (progresses[i] >= 100)
{
arr_days[i] = count;
break;
}
}
}
for (int i = 1; i < size; i++)
{
if (arr_days[i] < arr_days[i - 1])
arr_days[i] = arr_days[i - 1];
}
for (int i = 0; i < size; i++)
tmp_map[arr_days[i]]++;
for (auto& item : tmp_map)
answer.push_back(item.second);
return answer;
}
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
[2] 오픈 채팅방 (0) | 2022.08.11 |
---|---|
[2] 이진 변환 반복하기 (0) | 2022.08.11 |
[1] 신고 결과 받기 (0) | 2022.05.31 |
[3] 여행경로 (0) | 2022.05.31 |
[3] N으로 표현 (0) | 2022.05.31 |