結果

問題 No.5 数字のブロック
ユーザー stady0sh
提出日時 2017-05-30 20:14:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 35 ms / 5,000 ms
コード長 730 bytes
コンパイル時間 893 ms
コンパイル使用メモリ 110,232 KB
実行使用メモリ 28,084 KB
最終ジャッジ日時 2024-11-18 11:11:42
合計ジャッジ時間 3,038 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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(int.Parse).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