import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
public class NUM42586 {
public static void main(String[] args) {
int[] progresses = {95, 90, 99, 99, 80, 99};
int[] speeds = {1, 1, 1, 1, 1, 1};
System.out.println(solution(progresses, speeds));
}
public static int[] solution(int[] progresses, int[] speeds) {
int[] answer = {};
ArrayList<Integer> counts = new ArrayList<>();
Queue<Integer> days = new LinkedList<>();
for (int i = 0; i < progresses.length; i++) {
if ((100 - progresses[i]) % speeds[i] == 0) days.add((100 - progresses[i]) / speeds[i]);
else days.add((100 - progresses[i]) / speeds[i] + 1);
}
int day = days.poll();
int count = 1;
while (!days.isEmpty()) {
if (day >= days.peek()) {
days.poll();
count++;
} else {
counts.add(count);
day = days.poll();
count = 1;
}
}
counts.add(count);
answer = new int[counts.size()];
for (int i = 0; i < counts.size(); i++) {
answer[i] = counts.get(i);
}
return answer;
}
}
*다른 분들의 코드를 참고하여 작성했습니다