File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed
Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change 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
1616
1717### 제출 일자
1818
19- 2025년 04월 03일 18:22:00
19+ 2025년 05월 13일 20:36:10
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments