結果

問題 No.5 数字のブロック
ユーザー しらゆきしらゆき
提出日時 2015-11-18 10:01:54
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 546 bytes
コンパイル時間 3,578 ms
コンパイル使用メモリ 104,680 KB
実行使用メモリ 26,200 KB
最終ジャッジ日時 2023-08-11 14:20:03
合計ジャッジ時間 7,235 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
21,724 KB
testcase_01 AC 61 ms
21,600 KB
testcase_02 AC 60 ms
21,692 KB
testcase_03 AC 72 ms
20,164 KB
testcase_04 AC 70 ms
22,124 KB
testcase_05 AC 73 ms
22,064 KB
testcase_06 AC 71 ms
22,088 KB
testcase_07 AC 72 ms
23,964 KB
testcase_08 AC 71 ms
22,084 KB
testcase_09 AC 71 ms
23,912 KB
testcase_10 AC 72 ms
22,276 KB
testcase_11 AC 71 ms
21,988 KB
testcase_12 AC 72 ms
22,052 KB
testcase_13 AC 74 ms
24,180 KB
testcase_14 AC 62 ms
21,676 KB
testcase_15 AC 68 ms
21,872 KB
testcase_16 AC 72 ms
22,116 KB
testcase_17 AC 73 ms
22,292 KB
testcase_18 AC 74 ms
26,200 KB
testcase_19 AC 72 ms
20,200 KB
testcase_20 AC 62 ms
21,624 KB
testcase_21 AC 62 ms
21,564 KB
testcase_22 AC 60 ms
21,732 KB
testcase_23 AC 60 ms
21,584 KB
testcase_24 AC 69 ms
23,840 KB
testcase_25 AC 68 ms
21,816 KB
testcase_26 AC 60 ms
21,596 KB
testcase_27 AC 59 ms
21,788 KB
testcase_28 AC 58 ms
23,900 KB
testcase_29 AC 71 ms
20,072 KB
testcase_30 AC 69 ms
21,880 KB
testcase_31 AC 58 ms
19,660 KB
testcase_32 AC 59 ms
21,744 KB
testcase_33 AC 59 ms
21,640 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

class Program
{
    static void Main()
    {
        int l = int.Parse(Console.ReadLine());
        int n = int.Parse(Console.ReadLine());
        int[] w = Console.ReadLine().Split().Select(int.Parse).ToArray();

        Array.Sort(w);
        int cnt = 0;
        int leng = 0;

        for(int i=0;i< n; i++)
        {
            if (leng + w[i] <= l)
            {
                leng += w[i];
                cnt++;
            }
            else break;
        }

        Console.WriteLine(cnt);
    }
}
0