File tree 3 files changed +36
-0
lines changed
3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ package BOJ ;
2
+
3
+ import java .io .BufferedReader ;
4
+ import java .io .IOException ;
5
+ import java .io .InputStreamReader ;
6
+ import java .util .Arrays ;
7
+
8
+ public class BOJ_1339 {
9
+ public static void main (String [] args ) throws IOException {
10
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
11
+ int N = Integer .parseInt (br .readLine ());
12
+ int [] alpha = new int [26 ];
13
+
14
+ int ans = 0 ;
15
+ int val = 9 ;
16
+
17
+ for (int i = 0 ;i < N ; i ++) {
18
+ char [] arr = br .readLine ().toCharArray ();
19
+ int pos = (int ) Math .pow (10 , arr .length - 1 );
20
+
21
+ for (int j =0 ; j < arr .length ; j ++) {
22
+ alpha [arr [j ] - 'A' ] += pos ;
23
+ pos /= 10 ;
24
+ }
25
+ }
26
+
27
+ Arrays .sort (alpha );
28
+
29
+ for (int i = alpha .length - 1 ; i >= 0 ; i --) {
30
+ if (val == 0 ) break ;
31
+ ans += alpha [i ] * val --;
32
+ }
33
+ System .out .println (ans );
34
+
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments