結果

問題 No.5 数字のブロック
ユーザー stady0sh
提出日時 2017-05-30 20:44:38
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 738 bytes
コンパイル時間 787 ms
コンパイル使用メモリ 110,072 KB
実行使用メモリ 29,468 KB
最終ジャッジ日時 2024-11-18 11:12:08
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge1 / 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.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YukiCoder_Cs
{
    class Program
    {
        public static void Main()
        {
            int L = int.Parse(Console.ReadLine().Trim());   // 箱の幅
            int N = int.Parse(Console.ReadLine().Trim());   // 箱の数
            int[] BoxList = Console.ReadLine().Trim().Split(' ').Select(s => int.Parse(s)).ToArray();
            Array.Sort(BoxList);
            int cnt = 0;
            for (int i = 0;i < N; ++i)
            {
                L -= BoxList[i];
                if (L < 0) { break; }
                ++cnt;
            }

            Console.WriteLine($"{cnt}");

        }
    }
}
0