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 a1203f8 commit 9a1853dCopy full SHA for 9a1853d
JHLEE325/202507/22 BOJ G4 카드 정렬하기.md
@@ -0,0 +1,33 @@
1
+```java
2
+import java.io.BufferedReader;
3
+import java.io.InputStreamReader;
4
+import java.util.*;
5
+
6
+public class Main {
7
8
+ static List<Deque<Integer>> wheel = new ArrayList<>();
9
10
+ public static void main(String[] args) throws Exception {
11
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
12
+ StringTokenizer st;
13
14
+ int n = Integer.parseInt(br.readLine());
15
+ Queue<Integer> q = new PriorityQueue<>();
16
17
+ for (int i = 0; i < n; i++) {
18
+ q.add(Integer.parseInt(br.readLine()));
19
+ }
20
21
+ int result = 0;
22
+ while (q.size() != 1) {
23
+ int a = q.poll();
24
+ int b = q.poll();
25
+ result += a + b;
26
+ q.add(a + b);
27
28
29
+ System.out.println(result);
30
31
+}
32
33
+```
0 commit comments