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); + } +} + +```