Skip to content

Commit 4cd14bc

Browse files
authored
[20251114] PGM / LV2 / 최솟값 만들기 / 이종환
1 parent f342bd1 commit 4cd14bc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
```java
2+
import java.io.*;
3+
import java.util.*;
4+
5+
class Solution
6+
{
7+
public int solution(int []A, int []B)
8+
{
9+
10+
PriorityQueue<Integer> pq = new PriorityQueue<>();
11+
PriorityQueue<Integer> rPq = new PriorityQueue<>(Collections.reverseOrder());
12+
for (int n: A){
13+
pq.add(n);
14+
}
15+
for (int n: B){
16+
rPq.add(n);
17+
}
18+
19+
int ans = 0;
20+
for (int i = 0; i < A.length; i++){
21+
ans += pq.poll() * rPq.poll();
22+
}
23+
24+
return ans;
25+
}
26+
}
27+
```

0 commit comments

Comments
 (0)