문제
입출력
문제풀이
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> answer;
vector<int> days;
int day = 0;
//진도가 100일때 서비스 반영이 가능하다.
//배포되어야 하는 순서대로 작업진도 배열과 작업개발속도가 적인 배열 주어짐.
//배포는 하루에 한번만 할수 있고, 하루의 끝에. 95%인데 4라면 배포는 2일 뒤에 이뤄진다.
for(int i =0;i<progresses.size();i++){
while(progresses[i] != 100 && progresses[i] < 100){
progresses[i] += speeds[i];
day++;
}
if(progresses[i] >= 100){
days.push_back(day);day = 0;
}
}
int first = 1;
//[7,3,9]
//[5,10,1,1,20,1]
//7일차때 이미 모든 일들은 계쏙 같이 진행 중이였던 상황.
for(int i = 1;i<days.size()+1;i++){
if(days[i] <= days[i-1]){
first++;
}
else{
answer.push_back(first);
first = 1;
}
}
return answer;
}
'programming language > Structure' 카테고리의 다른 글
std::stack, std::queue, std::priority_queue (0) | 2021.07.29 |
---|---|
[프로그래머스 Level2 스택] 프린터 (0) | 2021.07.28 |
std::vector, std::deque (0) | 2021.07.28 |
std::array (0) | 2021.07.26 |
연속된 자료구조 vs 연결된 자료구조 (0) | 2021.07.26 |