結果

問題 No.5 数字のブロック
ユーザー masaktmasakt
提出日時 2017-03-21 01:37:51
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 620 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 106,724 KB
実行使用メモリ 26,972 KB
最終ジャッジ日時 2024-11-18 10:57:34
合計ジャッジ時間 2,859 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
class P
{
    static void Main(string[] _)
    {
        int l = int.Parse(Console.ReadLine());
        int n = int.Parse(Console.ReadLine());
        _ = Console.ReadLine().Split(' ');
        int[] w = new int[n];
        for (int i = 0; i < n; i++)
        {
            w[i] = int.Parse(_[i]);
        }
        Array.Sort(w);
        int c = 0;
        for (int i = 0; i < n; i++)
        {
            l -= w[i];
            if (l < 0)
            {
                break;
            }
            else
            {
                c++;
            }
        }
        Console.WriteLine(c);
    }
}
0