알고리즘 문제
[프로그래머스] 기능개발
feelcoding
2020. 7. 31. 00:10
728x90
https://programmers.co.kr/learn/courses/30/lessons/42586
코딩테스트 연습 - 기능개발
프로그래머스 팀에서는 기능 개선 작업을 수행 중입니다. 각 기능은 진도가 100%일 때 서비스에 반영할 수 있습니다. 또, 각 기능의 개발속도는 모두 다르기 때문에 뒤에 있는 기능이 앞에 있는 ��
programmers.co.kr
#include <string>
#include <vector>
#include <cmath>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> answer;
int n = ceil((100 - progresses[0]) / (double)speeds[0]);
int num = 1;
for (int i = 1; i < progresses.size(); i++) {
if (ceil((100 - progresses[i]) / (double)speeds[i]) <= n) {
num++;
}
else {
answer.push_back(num);
num = 1;
n = ceil((100 - progresses[i]) / (double)speeds[i]);
}
}
answer.push_back(num);
return answer;
}
비주얼 스튜디오에서는 <cmath> 헤더를 포함해주지 않아도 잘 돌아갔지만 프로그래머스에 제출할 때에는 돌아가지 않았다. ceil 함수를 사용할 때에는 <cmath>를 포함하자.
그냥 문제에 있는 그대로 구현해주면 된다.
728x90