알고리즘/시뮬레이션
[프로그래머스]기능개발
안잡아모찌
2019. 10. 24. 16:50
https://programmers.co.kr/learn/courses/30/lessons/42586?language=cpp
코딩테스트 연습 - 기능개발 | 프로그래머스
프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다. 또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는 기능보다 먼저 개발될 수 있고, 이때 뒤에 있는 기능은 앞에 있는 기능이 배포될 때 함께 배포됩니다. 먼저 배포되어야 하는 순서대로 작업의 진도가 적힌 정수 배열 progresses와 각 작업의 개발 속도가 적힌 정수 배열 speeds가 주어질 때 각 배포마다 몇
programmers.co.kr
큐 느낌의 시뮬레이션. 인덱스로 조절했다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <string> #include <vector> using namespace std; vector<int> solution(vector<int> progresses, vector<int> speeds) { vector<int> answer; int Day=0; while(1){ for(int i=0;i<speeds.size();i++) progresses[i]+=speeds[i]; int cnt=0; for(int i=Day;i<speeds.size();i++){ if(progresses[i]>=100) Day++,cnt++; else break; } if(cnt) answer.push_back(cnt); if(Day==speeds.size()) break; } return answer; } | cs |