YeJin's Footsteps

기능 개발 본문

Computer Science & Engineering/알고리즘

기능 개발

YeJinii 2021. 7. 2. 11:03

문제 링크

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

 

코딩테스트 연습 - 기능개발

프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다. 또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는

programmers.co.kr

 

문제 코드 풀이

#include <string>
#include <vector>
#include <iostream>

using namespace std;

vector<int> solution(vector<int> progresses, vector<int> speeds) {
    
    vector<int> answer;
    vector<int> day;
    
    for(int i=0; i<progresses.size(); i++){
        if((100-progresses[i])%speeds[i]==0){
            day.push_back((100-progresses[i])/speeds[i]);
        }else{
            day.push_back((100-progresses[i])/speeds[i]+1);
        }
    }
    int p=day[0]; int cnt=0;
    for(int i=0; i<day.size(); i++){
        if(p>=day[i]) cnt++;
        else {
            answer.push_back(cnt);
            p=day[i];
            cnt=1;
        } 
    }
    answer.push_back(cnt);
    return answer;
}

'Computer Science & Engineering > 알고리즘' 카테고리의 다른 글

Algorithm Study_0703  (0) 2021.07.03
프린터  (0) 2021.07.02
H-Index  (0) 2021.07.01
가장 큰 수  (0) 2021.07.01
불량사용자  (0) 2021.05.07
Comments