結果

問題 No.5 数字のブロック
コンテスト
ユーザー 大谷祐翔
提出日時 2025-10-29 11:32:20
言語 C#
(.NET 8.0.404)
結果
WA  
実行時間 -
コード長 892 bytes
コンパイル時間 16,309 ms
コンパイル使用メモリ 170,568 KB
実行使用メモリ 187,228 KB
最終ジャッジ日時 2025-10-29 11:32:40
合計ジャッジ時間 10,418 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (110 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
class Program
{
    static void Main(string[] args)
    {
        string inputWidth = Console.ReadLine()!;
        string inputCount = Console.ReadLine()!;
        string[] inputBlock = Console.ReadLine()!.Split(' ');

        int width = int.Parse(inputWidth);
        int count = int.Parse(inputCount);
        int[] blockArray = new int[inputBlock.Length];

        for (int i = 0; i < inputBlock.Length; i++)
        {
            blockArray[i] = int.Parse(inputBlock[i]);
        }

        Array.Sort(blockArray);

        int output = 0;
        int sum = 0;
        for (int i = 0; i < blockArray.Length; i++)
        {
            sum = sum + blockArray[i];
            if (sum < width)
            {
                output++;
            }
            else
            {
                Console.WriteLine(output);
                break;
            }
        }
    }
}
0