結果

問題 No.164 ちっちゃくないよ!!
ユーザー tentententen
提出日時 2020-10-14 11:56:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 180 ms / 2,000 ms
コード長 815 bytes
コンパイル時間 2,119 ms
コンパイル使用メモリ 71,124 KB
実行使用メモリ 57,876 KB
最終ジャッジ日時 2023-09-28 00:32:08
合計ジャッジ時間 4,812 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,724 KB
testcase_01 AC 133 ms
55,616 KB
testcase_02 AC 129 ms
55,960 KB
testcase_03 AC 128 ms
55,812 KB
testcase_04 AC 129 ms
55,812 KB
testcase_05 AC 177 ms
56,440 KB
testcase_06 AC 168 ms
56,436 KB
testcase_07 AC 167 ms
56,100 KB
testcase_08 AC 179 ms
55,904 KB
testcase_09 AC 180 ms
56,600 KB
testcase_10 AC 134 ms
57,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	long min = Long.MAX_VALUE;
    	for (int i = 0; i < n; i++) {
    	    min = Math.min(min, getValue(sc.next().toCharArray()));
    	}
    	System.out.print(min);
	}

	static long getValue(char[] arr) {
	    char max = '0';
	    for (char c : arr) {
	        max = (char)Math.max(max, c);
	    }
	    int idxed = 0;
	    if (max >= 'A') {
	        idxed = 10 + max - 'A';
	    } else {
	        idxed = max - '0';
	    }
	    idxed++;
	    long value = 0;
	    for (char c : arr) {
	        value *= idxed;
	        if (c >= 'A') {
	            value += 10 + c - 'A';
	        } else {
	            value += c - '0';
	        }
	    }
	    return value;
	}
}
0