Level
프로그래머스 Lv2
Recruitment
function solution(progresses, speeds) {
  var answer = [];
  let count = 1;
  const days = progresses.map((p, i) => Math.ceil((100 - p) / speeds[i]));
  let current = days[0];

  for (let i = 0; i < days.length; i++) {
    const nextDay = days[i + 1];
    if (current < (nextDay || Infinity)) {
      answer.push(count);
      current = nextDay;
      count = 1;
    } else {
      count++;
    }
  }

  return answer;
  // 4 2 3 4 2 7 12 4 2 31
  // 4 4 4 4 4 7 12 12 12 31
}