File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 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+ ```
You can’t perform that action at this time.
0 commit comments