[프로그래머스 / C++] 기능개발

Seulguo·2022년 7월 3일
0

Algorithm

목록 보기
1/185
post-thumbnail
post-custom-banner

🐣 문제

링크 : https://programmers.co.kr/learn/courses/30/lessons/42586


🐥 코드

#include <string>
#include <vector>
#include <queue>

using namespace std;

vector<int> solution(vector<int> progresses, vector<int> speeds) {
    vector<int> answer;
    queue<int> q;
    
    for(int i = 0; i < progresses.size(); i++){
        int day = (100 - progresses[i] / speeds[i];
        if((day * speeds[i] + progresses[i]) != 100) day++;
        q.push(day);
    }
    
    while(!q.empty()){
        int release = q.front();
        q.pop();
        int sum = 1;
        
        while((!q.empty()) && (release >= q.front())){
            q.pop();
            sum ++;
        }
        answer.push_back(sum);
    }
    
    return answer;
}
post-custom-banner

0개의 댓글