結果

問題 No.164 ちっちゃくないよ!!
ユーザー tentententen
提出日時 2022-10-13 11:04:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,685 bytes
コンパイル時間 2,127 ms
コンパイル使用メモリ 74,648 KB
実行使用メモリ 51,832 KB
最終ジャッジ日時 2023-09-08 19:01:16
合計ジャッジ時間 3,998 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,400 KB
testcase_01 AC 45 ms
49,148 KB
testcase_02 AC 43 ms
49,128 KB
testcase_03 AC 44 ms
49,156 KB
testcase_04 AC 44 ms
49,208 KB
testcase_05 AC 80 ms
51,500 KB
testcase_06 AC 81 ms
51,192 KB
testcase_07 AC 57 ms
50,444 KB
testcase_08 AC 68 ms
51,832 KB
testcase_09 AC 76 ms
50,956 KB
testcase_10 AC 47 ms
49,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        HashMap<Character, Integer> convert = new HashMap<>();
        for (int i = 0; i < 10; i++) {
            convert.put((char)(i + '0'), i);
        }
        for (int i = 0; i < 26; i++) {
            convert.put((char)(i + 'A'), i + 10);
        }
        long min = Long.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            char[] values = sc.next().toCharArray();
            int max = 0;
            for (char c : values) {
                max = Math.max(max, convert.get(c));
            }
            max++;
            long ans = 0;
            for (char c : values) {
                ans *= max;
                ans += convert.get(c);
            }
            min = Math.min(min, ans);
        }
        System.out.println(min);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0