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