結果

問題 No.164 ちっちゃくないよ!!
ユーザー tentententen
提出日時 2023-02-14 15:22:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 2,200 bytes
コンパイル時間 4,771 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 51,752 KB
最終ジャッジ日時 2023-09-24 04:17:34
合計ジャッジ時間 3,736 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
49,264 KB
testcase_01 AC 38 ms
49,232 KB
testcase_02 AC 38 ms
49,204 KB
testcase_03 AC 38 ms
49,400 KB
testcase_04 AC 38 ms
49,140 KB
testcase_05 AC 59 ms
49,476 KB
testcase_06 AC 64 ms
51,752 KB
testcase_07 AC 50 ms
49,876 KB
testcase_08 AC 57 ms
50,792 KB
testcase_09 AC 58 ms
51,044 KB
testcase_10 AC 41 ms
49,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        HashMap<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < 10; i++) {
            map.put((char)(i + '0'), i);
        }
        for (int i = 0; i < 26; i++) {
            map.put((char)(i + 'A'), i + 10);
        }
        long ans = Long.MAX_VALUE;
        while (n-- > 0) {
            char[] inputs = sc.next().toCharArray();
            int max = 0;
            for (char c : inputs) {
                max = Math.max(max, map.get(c));
            }
            int base = max + 1;
            long current = 0;
            for (char c : inputs) {
                current *= base;
                current += map.get(c);
            }
            ans = Math.min(ans, current);
        }
        System.out.println(ans);
    }
    
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0