File tree Expand file tree Collapse file tree 2 files changed +11
-39
lines changed
Expand file tree Collapse file tree 2 files changed +11
-39
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 88 .7 MB, 시간: 20.54 ms
7+ 메모리: 78 .7 MB, 시간: 4.16 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2025년 06월 02일 12:06:35
19+ 2025년 06월 02일 12:47:46
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 22
33class Solution {
44 PriorityQueue <job > q ;
5- int t ;
5+ int t , idx , finished_jobs , workingTime ;
66 int [][] jobs ;
77
88 public int solution (int [][] jobs ) {
@@ -12,58 +12,30 @@ public int solution(int[][] jobs) {
1212 }
1313
1414 int working (){
15- int answer ;
1615 int [] now ;
1716 job pre ;
1817
19- answer = 0 ;
20- for (int i = 0 ; i < jobs .length ; i ++){
21- now = jobs [i ];
22- if (t < now [0 ]){
23-
24- if (q .isEmpty ()) t = now [0 ];
25- else i --;
26- }
18+ while (finished_jobs != jobs .length ){
19+ idx = putQOvertime (idx , t );
2720
28- if (now [0 ] <= t ) i = putQOvertime (i , t );
2921 if (!q .isEmpty ()){
3022 pre = q .poll ();
31- answer += calculation (pre );
32-
33- }
34- }
35-
36- while (!q .isEmpty ()){
37- pre = q .poll ();
38-
39- answer += calculation (pre );
40- }
41-
42- return answer / jobs .length ;
43- }
44-
45- int calculation (job pre ){
46- int answer ;
47-
48- if (t < pre .s ){ // 시작시간을 지나지 않은 경우
49- answer = pre .t ;
50- t = pre .t + pre .s ;
51-
52- }else { // 시작시간을 지난 경우
53- answer = (t - pre .s ) + pre .t ;
23+
24+ workingTime += (t - pre .s ) + pre .t ;
5425 t += pre .t ;
26+ finished_jobs ++;
27+ } else t = jobs [idx ][0 ];
5528 }
56- System .out .println (pre .n + " " + t );
5729
58- return answer ;
30+ return workingTime / jobs . length ;
5931 }
6032
6133 int putQOvertime (int j , int t ){
6234 while (j < jobs .length && jobs [j ][0 ] <= t ){
6335 q .add (new job (j , jobs [j ][0 ], jobs [j ][1 ]));
6436 j ++;
6537 }
66- return -- j ;
38+ return j ;
6739 }
6840
6941 void setting (int [][] jobs ) {
You can’t perform that action at this time.
0 commit comments