結果

問題 No.164 ちっちゃくないよ!!
ユーザー bluemeganebluemegane
提出日時 2020-09-11 20:04:57
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,071 bytes
コンパイル時間 811 ms
コンパイル使用メモリ 67,888 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2023-08-27 05:37:35
合計ジャッジ時間 2,173 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
22,784 KB
testcase_01 AC 59 ms
22,696 KB
testcase_02 AC 59 ms
20,732 KB
testcase_03 AC 59 ms
20,816 KB
testcase_04 AC 59 ms
22,728 KB
testcase_05 AC 60 ms
20,876 KB
testcase_06 AC 61 ms
20,952 KB
testcase_07 AC 60 ms
20,824 KB
testcase_08 AC 61 ms
20,804 KB
testcase_09 AC 61 ms
22,708 KB
testcase_10 AC 59 ms
20,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System.Collections.Generic;
using static System.Math;
using System;

public class Hello
{
    public static Dictionary<char, int> d;
    static void Main()
    {
        var s = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        d = new Dictionary<char, int>();
        for (int i = 0; i < 36; i++) d[s[i]] = i;
        var n = int.Parse(Console.ReadLine().Trim());
        var amin = long.MaxValue;
        for (int i = 0; i < n; i++)
        {
            var a = Console.ReadLine().Trim();
            var maxc = getMaxc(a);
            amin = Min(amin, calc(a, maxc + 1));
        }
        Console.WriteLine(amin);

    }
    static long calc(string s, int n)
    {
        var s2 = s.ToCharArray();
        Array.Reverse(s2);
        var res = 0L;
        var sL = s.Length;
        var ex = 1L;
        foreach (var x in s2)
        {
            res += ex * d[x];
            ex *= n;
        }
        return res;
    }
    static int getMaxc(string s)
    {
        var res = 0;
        foreach (var x in s) res = Max(res, d[x]);
        return res;
    }
}
0