結果
問題 |
No.164 ちっちゃくないよ!!
|
ユーザー |
![]() |
提出日時 | 2022-10-13 11:04:36 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 85 ms / 2,000 ms |
コード長 | 1,685 bytes |
コンパイル時間 | 3,005 ms |
コンパイル使用メモリ | 78,760 KB |
実行使用メモリ | 38,492 KB |
最終ジャッジ日時 | 2024-06-26 11:57:04 |
合計ジャッジ時間 | 3,574 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
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(); } }