結果

問題 No.5 数字のブロック
ユーザー cccccc
提出日時 2022-07-15 19:33:20
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 58 ms / 5,000 ms
コード長 840 bytes
コンパイル時間 13,361 ms
コンパイル使用メモリ 147,064 KB
実行使用メモリ 162,704 KB
最終ジャッジ日時 2023-09-09 22:02:45
合計ジャッジ時間 16,683 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
29,044 KB
testcase_01 AC 53 ms
29,196 KB
testcase_02 AC 49 ms
29,156 KB
testcase_03 AC 55 ms
29,852 KB
testcase_04 AC 55 ms
29,764 KB
testcase_05 AC 56 ms
30,064 KB
testcase_06 AC 56 ms
29,640 KB
testcase_07 AC 55 ms
31,632 KB
testcase_08 AC 57 ms
29,584 KB
testcase_09 AC 56 ms
31,564 KB
testcase_10 AC 56 ms
29,892 KB
testcase_11 AC 57 ms
31,684 KB
testcase_12 AC 57 ms
29,836 KB
testcase_13 AC 56 ms
29,908 KB
testcase_14 AC 55 ms
29,320 KB
testcase_15 AC 55 ms
29,352 KB
testcase_16 AC 57 ms
31,936 KB
testcase_17 AC 58 ms
31,976 KB
testcase_18 AC 57 ms
30,012 KB
testcase_19 AC 57 ms
30,208 KB
testcase_20 AC 52 ms
29,280 KB
testcase_21 AC 52 ms
29,072 KB
testcase_22 AC 52 ms
29,228 KB
testcase_23 AC 54 ms
29,052 KB
testcase_24 AC 56 ms
29,456 KB
testcase_25 AC 54 ms
29,476 KB
testcase_26 AC 52 ms
29,276 KB
testcase_27 AC 52 ms
29,256 KB
testcase_28 AC 50 ms
28,928 KB
testcase_29 AC 56 ms
29,592 KB
testcase_30 AC 56 ms
31,520 KB
testcase_31 AC 49 ms
28,828 KB
testcase_32 AC 49 ms
29,080 KB
testcase_33 AC 49 ms
162,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  Determining projects to restore...
  Restored /home/judge/data/code/main.csproj (in 136 ms).
.NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f
Copyright (C) Microsoft Corporation.All rights reserved.

  プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください
  main -> /home/judge/data/code/bin/Release/net6.0/main.dll
  main -> /home/judge/data/code/bin/Release/net6.0/publish/

ソースコード

diff #

using System;
using System.Linq;
class Program
{
    static void Main()
    {
        /// 16 : 規定箱の幅
        /// 3  : 挿入箱の数
        /// 10 5 7 : 挿入箱の幅

        // 標準入力
        var spfBox = int.Parse(Console.ReadLine());
        var boxCnt = int.Parse(Console.ReadLine());
        var aryBox = Console.ReadLine().Split().Select(int.Parse).ToArray();

        // 配列を降順でソート
        Array.Sort(aryBox);

        // 空変数定義
        var ansBox = 0;
        var ansCnt = 0;

        // 変数に最小値から代入し規定値を超えていないかチェック
        for (var i = 0; i < boxCnt; i++)
        {
            if ((ansBox += aryBox[i]) > spfBox)
                break;
            else
                ansCnt++;
        }
        Console.WriteLine(ansCnt);

    }
}
0