We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4561e17 commit 28c27d5Copy full SHA for 28c27d5
03do-new30/202507/22 BOJ G4 카드 정렬하기.md
@@ -0,0 +1,24 @@
1
+```java
2
+import java.util.*;
3
+import java.io.*;
4
+
5
+public class Main {
6
+ public static void main(String[] args) throws IOException {
7
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8
+ int N = Integer.parseInt(br.readLine());
9
+ PriorityQueue<Integer> pq = new PriorityQueue<>();
10
+ for (int i = 0; i < N; i++) {
11
+ pq.offer(Integer.parseInt(br.readLine()));
12
+ }
13
+ int sum = 0;
14
+ while (pq.size() >= 2) {
15
+ int a = pq.poll();
16
+ int b = pq.poll();
17
+ pq.offer(a + b);
18
+ sum += a + b;
19
20
+ System.out.println(sum);
21
+ br.close();
22
23
+}
24
+```
0 commit comments