結果

問題 No.5 数字のブロック
ユーザー Maeda
提出日時 2025-03-31 11:18:34
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 809 bytes
コンパイル時間 8,260 ms
コンパイル使用メモリ 169,704 KB
実行使用メモリ 193,760 KB
最終ジャッジ日時 2025-03-31 11:18:54
合計ジャッジ時間 14,470 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 7 RE * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (113 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

    class Program
    {
        /// <summary>
        /// コンストラクタ
        /// </summary>
        static void Main()
        {
            int l = int.Parse(Console.ReadLine()!);
            int n = int.Parse(Console.ReadLine()!);
            string size = Console.ReadLine()!;
            string[] CharSize = size.Split(' ');
            int[] sizeList = new int[n];
            for (int i = 0; i < n; i++)
            {
                sizeList[i] = int.Parse(CharSize[i]);
            }
            Array.Sort(sizeList);

            int count = 0;
            int nowSize = 0;
            while (nowSize + sizeList[count] < l && count < n)
            {
                nowSize += sizeList[count];
                count++;
            }

            Console.WriteLine(count);

        }
    }
0