結果

問題 No.256 桁の数字を入れ替え (2)
ユーザー Maeda
提出日時 2025-04-09 09:37:08
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 1,207 bytes
コンパイル時間 7,328 ms
コンパイル使用メモリ 171,104 KB
実行使用メモリ 192,364 KB
最終ジャッジ日時 2025-04-09 09:37:17
合計ジャッジ時間 8,767 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (92 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            List<char> chars = ChangeCharArray(str);
            int[] countList = new int[10];
            countList = NumberCount(countList, chars);
            Array.Reverse(countList);
            for(int i = 0; i < 10; i++)
            {
                PushNumber(i,countList);
            }
            Console.WriteLine();
        }

        private static void PushNumber(int nowNumber, int[] countList)
        {
            for (int i = 0; i < countList[nowNumber]; i++)
            {
                Console.Write(9 - nowNumber);
            }
        }

        private static int[] NumberCount(int[] countList, List<char> chars)
        {
            foreach (char c in chars)
            {
                countList[int.Parse(c.ToString())]++;
            }
            return countList;
        }

        private static List<char> ChangeCharArray(string str)
        {
            List<char> chars = new List<char>();
            for (int i = 0; i < str.Length; i++)
            {
                chars.Add(str[i]);
            }
            return chars;
        }
    }
0