From 5ef03667d0476c009e3d564cf4cb9bbdaa9270d7 Mon Sep 17 00:00:00 2001 From: JHLEE325 <82587652+JHLEE325@users.noreply.github.com> Date: Sat, 23 Aug 2025 20:30:14 +0900 Subject: [PATCH] =?UTF-8?q?[20250823]=20BOJ=20/=20G4=20/=20=EB=8B=A8?= =?UTF-8?q?=EC=96=B4=20=EC=88=98=ED=95=99=20/=20=EC=9D=B4=EC=A4=80?= =?UTF-8?q?=ED=9D=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\226\264 \354\210\230\355\225\231.md" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "JHLEE325/202508/23 BOJ G4 \353\213\250\354\226\264 \354\210\230\355\225\231.md" diff --git "a/JHLEE325/202508/23 BOJ G4 \353\213\250\354\226\264 \354\210\230\355\225\231.md" "b/JHLEE325/202508/23 BOJ G4 \353\213\250\354\226\264 \354\210\230\355\225\231.md" new file mode 100644 index 00000000..f58fc587 --- /dev/null +++ "b/JHLEE325/202508/23 BOJ G4 \353\213\250\354\226\264 \354\210\230\355\225\231.md" @@ -0,0 +1,37 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws Exception { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int N = Integer.parseInt(br.readLine()); + + int[] weight = new int[26]; + + for (int i = 0; i < N; i++) { + String word = br.readLine(); + int len = word.length(); + for (int j = 0; j < len; j++) { + char c = word.charAt(j); + weight[c - 'A'] += Math.pow(10, len - j - 1); + } + } + + PriorityQueue pq = new PriorityQueue<>(Collections.reverseOrder()); + for (int w : weight) { + if (w > 0) pq.add(w); + } + + int num = 9; + int sum = 0; + while (!pq.isEmpty()) { + int val = pq.poll(); + sum += val * num--; + } + + System.out.println(sum); + } +} + +```