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

using namespace std;

vector<int> solution(vector<int> progresses, vector<int> speeds) {
    vector<int> answer;
    queue <int> left_day;
    int day = 0;
    for(int i =0; i < progresses.size(); i++){
        int cal = (100-progresses[i]) % speeds[i];
        int cal2 = (100-progresses[i]) / speeds[i];
        if(cal != 0){
            left_day.push(cal2+1);
        }
        else 
            left_day.push(cal2);
    }
    while(!left_day.empty()){
        day = 0;
        int now_n = left_day.front();
        left_day.pop();
        day+=1;
        while(!left_day.empty()){
            int next_n = left_day.front();
            if(now_n >= next_n){
                left_day.pop();
                day+=1;
            }
            else
                break;
        }
        answer.push_back(day);
    }
    return answer;
}

'자윤이와고리즘 > Code' 카테고리의 다른 글

[프로그래머스] 큰 수 만들기  (0) 2019.07.22
[프로그래머스] 쇠막대기  (0) 2019.07.22
[프로그래머스] 스킬트리  (0) 2019.07.22
[프로그래머스] 탑  (0) 2019.07.22
[프로그래머스] 주식가격  (0) 2019.07.22

+ Recent posts