結果

問題 No.5 数字のブロック
ユーザー wowilson
提出日時 2016-10-07 16:49:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 656 bytes
コンパイル時間 1,052 ms
コンパイル使用メモリ 111,472 KB
実行使用メモリ 28,084 KB
最終ジャッジ日時 2024-11-18 09:44:29
合計ジャッジ時間 3,164 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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;
using System.Linq;

namespace Yukicoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var L = int.Parse(Console.ReadLine());
            var N = int.Parse(Console.ReadLine());

            var W = Console.ReadLine().Split(' ');
            int[] nums = W.Select(s => int.Parse(s)).ToArray();
            Array.Sort(nums);
            int sum = 0;
            int count = 0;
            foreach (var i in nums)
            {
                sum += i;
                if (sum > L)
                    break;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}
0