작업의 진도가 적힌 정수 배열 progresses와 각 작업의 개발 속도가 적힌 정수 배열 speeds가 주어질 때
각 배포마다 몇 개의 기능이 배포되는지 반환하는 문제
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <string> #include <vector> using namespace std; vector<int> solution(vector<int> progresses, vector<int> speeds) { vector<int> answer; int temp, max_day = 0; for (int i = 0; i < progresses.size(); i++) { temp = (100 - progresses[i]) / speeds[i]; if ((100 - progresses[i]) % speeds[i] != 0) temp++; if (answer.empty() || max_day < temp) { answer.push_back(1); max_day = temp; } else { answer.back()++; } } return answer; } | cs |
어렵진 않았으나 효율적으로 못짜서 다른 사람꺼 보고 수정함ㅎㅎ
'Algorithm > 프로그래머스' 카테고리의 다른 글
[프로그래머스/C++] 멀쩡한 사각형 (0) | 2021.02.19 |
---|---|
[프로그래머스/C++] 124 나라의 숫자 (0) | 2021.02.19 |
[프로그래머스/C++] 문자열 내 마음대로 정렬하기 (0) | 2021.02.16 |
[프로그래머스/C++] 나누어 떨어지는 숫자 배열 (0) | 2021.02.16 |
[프로그래머스/C++] 같은 숫자는 싫어 (0) | 2021.02.16 |