Skip to content

Commit eff27fb

Browse files
authored
[20250907] PGM / LV3 / 야근 지수 / 이강현
1 parent 0a45031 commit eff27fb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```java
2+
import java.util.*;
3+
class Solution {
4+
static PriorityQueue<Integer> pq = new PriorityQueue<>((a,b) -> Integer.compare(b,a));
5+
public long solution(int n, int[] works) {
6+
long answer = 0;
7+
for(int i : works){
8+
pq.offer(i);
9+
}
10+
for(int i=0;i<n;i++){
11+
if(!pq.isEmpty()){
12+
int cur = pq.poll();
13+
if(cur > 1){
14+
pq.offer(--cur);
15+
}
16+
}else{
17+
return 0;
18+
}
19+
}
20+
for(int i : pq){
21+
answer += i*i;
22+
}
23+
return answer;
24+
}
25+
}
26+
```

0 commit comments

Comments
 (0)