From cdbf985dcc5d7dcd1dcde7b92794490985753afd Mon Sep 17 00:00:00 2001 From: Jinyeong Seol Date: Tue, 21 Oct 2025 23:49:12 +0900 Subject: [PATCH] =?UTF-8?q?[20251021]=20BOJ=20/=20G4=20/=20=EB=8B=A8?= =?UTF-8?q?=EC=96=B4=20=EC=88=98=ED=95=99=20/=20=EC=84=A4=EC=A7=84?= =?UTF-8?q?=EC=98=81?= 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" | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 "Seol-JY/202510/21 BOJ G4 \353\213\250\354\226\264 \354\210\230\355\225\231.md" diff --git "a/Seol-JY/202510/21 BOJ G4 \353\213\250\354\226\264 \354\210\230\355\225\231.md" "b/Seol-JY/202510/21 BOJ G4 \353\213\250\354\226\264 \354\210\230\355\225\231.md" new file mode 100644 index 00000000..78c58917 --- /dev/null +++ "b/Seol-JY/202510/21 BOJ G4 \353\213\250\354\226\264 \354\210\230\355\225\231.md" @@ -0,0 +1,35 @@ +```java +import java.io.*; +import java.util.*; + +public class Main { + public static void main(String[] args) throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + int n = Integer.parseInt(br.readLine()); + + Map weights = new HashMap<>(); + + 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); + int weight = (int) Math.pow(10, len - 1 - j); + weights.put(c, weights.getOrDefault(c, 0) + weight); + } + } + + List weightList = new ArrayList<>(weights.values()); + weightList.sort((a, b) -> b - a); + + int result = 0; + int digit = 9; + for (int weight : weightList) { + result += weight * digit; + digit--; + } + + System.out.println(result); + } +} +```