Skip to content

Commit 34e3b35

Browse files
committed
[20251021] BOJ / G4 / 단어 수학 / 김민진
1 parent f5f32d8 commit 34e3b35

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
```java
2+
import java.io.*;
3+
import java.util.Arrays;
4+
5+
public class BJ_1339_단어_수학 {
6+
7+
private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
private static final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
9+
10+
private static int N, ans;
11+
private static int[] cnt;
12+
13+
public static void main(String[] args) throws IOException {
14+
init();
15+
sol();
16+
}
17+
18+
private static void init() throws IOException {
19+
N = Integer.parseInt(br.readLine());
20+
cnt = new int[26];
21+
ans = 0;
22+
23+
for (int i = 0; i < N; i++) {
24+
String input = br.readLine();
25+
26+
int len = input.length();
27+
for (int j = 0; j < len; j++) {
28+
cnt[input.charAt(j) - 'A'] += (int) Math.pow(10, len - 1 - j);
29+
}
30+
}
31+
Arrays.sort(cnt);
32+
}
33+
34+
private static void sol() throws IOException {
35+
int num = 9;
36+
37+
for (int i = 25; i >= 0 && num > 0; i--) {
38+
ans += cnt[i] * num--;
39+
}
40+
41+
bw.write(ans + "");
42+
bw.flush();
43+
bw.close();
44+
br.close();
45+
}
46+
47+
}
48+
```

0 commit comments

Comments
 (0)