[프로그래머스][C++] 기능개발
C++/알고리즘 문제2019. 9. 14. 16:45
문제: https://programmers.co.kr/learn/courses/30/lessons/42586
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> days;
for (int i=0;i<progresses.size();i++) {
int progress=progresses[i];
int speed=speeds[i];
int day=(100-progress)/speed;
if ((100-progress) % speed != 0) {
day++;
}
days.push_back(day);
}
vector<int> answer;
int delay=days[0];
int count=1;
for (int i=1;i<days.size();i++) {
if (days[i]>delay) {
delay=days[i];
answer.push_back(count);
count=1;
} else {
count++;
}
}
answer.push_back(count);
return answer;
}
'C++ > 알고리즘 문제' 카테고리의 다른 글
[프로그래머스][C++]추석 트래픽 (0) | 2019.09.14 |
---|---|
[프로그래머스][C++]스킬트리 (0) | 2019.09.14 |
댓글()