앞에 있는 기능이 먼저 배포되어야 한다.
즉, 앞에 있는 기능을 완료하는데 5일이 걸리고, 뒤 기능을 완료하는데 2일이 걸린다면
5일 동안 배포되지 못하다가 앞에 기능이 완료 되는 즉시 뒤 기능도 이미 완료 되었으므로 배포 가능하다
https://school.programmers.co.kr/learn/courses/30/lessons/42586#
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
작업은 동시에 시작된다
배포가 Block 될 뿐..!
따라서, 아래와 같은 예시를 생각해야 한다.
[85, 80, 90, 85] [5, 5, 5, 5] [1, 3]
import java.util.*;
class Solution {
public int[] solution(int[] progresses, int[] speeds) {
List<Integer> ans = new ArrayList<>();
for(int i = 0; i < progresses.length; i++) {
progresses[i] = (int)Math.ceil((double)(100 - progresses[i])/speeds[i]);
}
int cnt = 0;
int prev = progresses[0];
for(int i = 0; i < progresses.length; i++) {
if(prev >= progresses[i]) {
cnt += 1;
} else {
ans.add(cnt);
cnt = 1;
}
prev = Math.max(prev,progresses[i]);
}
if(cnt > 0) {
ans.add(cnt);
}
return ans.stream().mapToInt(Integer::intValue).toArray();
}
}
[BJ] 2258번 : 정육점 (0) | 2025.01.07 |
---|---|
[프로그래머스] 등대 : unsolved (0) | 2025.01.03 |
[프로그래머스] 연속 부분 수열 합의 개수 (0) | 2024.12.16 |
[프로그래머스] H-Index (0) | 2024.12.12 |
[프로그래머스] 같은 숫자는 싫어 (0) | 2024.12.12 |