Skip to content

Commit dfd9720

Browse files
committed
[level 3] Title: 디스크 컨트롤러, Time: 2.73 ms, Memory: 85.6 MB -BaekjoonHub
1 parent 9b4b666 commit dfd9720

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

프로그래머스/3/42627. 디스크 컨트롤러/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# [level 3] 디스크 컨트롤러 - 42627
22

3-
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/42627)
3+
[문제 링크](https://school.programmers.co.kr/learn/courses/30/lessons/42627?language=java)
44

55
### 성능 요약
66

7-
메모리: 9.31 MB, 시간: 10.09 ms
7+
메모리: 85.6 MB, 시간: 2.73 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2025년 04월 03일 18:22:00
19+
2025년 05월 13일 20:36:10
2020

2121
### 문제 설명
2222

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.util.*;
2+
class Solution {
3+
public int solution(int[][] jobs) {
4+
int answer = 0;
5+
Arrays.sort(jobs, (a,b)-> a[0]-b[0]);
6+
PriorityQueue<int[]> pq = new PriorityQueue<>((o1, o2) -> o1[1] - o2[1]);
7+
int idx = 0;
8+
int end = 0;
9+
int total = 0;
10+
while(answer < jobs.length){
11+
while(idx<jobs.length&&jobs[idx][0]<=end){
12+
pq.offer(jobs[idx++]);
13+
}
14+
if(pq.isEmpty()){
15+
end = jobs[idx][0];
16+
}else{
17+
int cur[] = pq.poll();
18+
total += cur[1] + end - cur[0];
19+
end += cur[1];
20+
answer++;
21+
}
22+
}
23+
24+
25+
return total/jobs.length;
26+
}
27+
}

0 commit comments

Comments
 (0)