結果

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

ソースコード

diff #

// namespaceは環境に応じて変更する
using System.Collections.Generic;

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(' ');
            List<int> sizeList = new List<int>();
            for (int i = 0; i < n; i++)
            {
                sizeList.Add(int.Parse(CharSize[i]));
            }
            for (int i = 0; i < n; i++)
            {
                for (int j = i; j < n; j++)
                {
                    if (sizeList[i] > sizeList[j])
                    {
                        int num = sizeList[i];
                        sizeList[i] = sizeList[j];
                        sizeList[j] = num;
                    }
                }
            }
            int count = 0;
            int nowSize = 0;
            while (nowSize + sizeList[count] < l && count < n)
            {
                count++;
            }

            Console.WriteLine(count);

    }

}
0