結果

問題 No.5 数字のブロック
ユーザー curryudon08curryudon08
提出日時 2020-03-04 23:45:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 668 bytes
コンパイル時間 3,783 ms
コンパイル使用メモリ 105,984 KB
実行使用メモリ 20,352 KB
最終ジャッジ日時 2024-10-14 00:36:18
合計ジャッジ時間 3,529 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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;
using System.Collections.Generic;

namespace _0005
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = long.Parse(Console.ReadLine());
            var n = long.Parse(Console.ReadLine());
            var w = Console.ReadLine().Split().Select(i => long.Parse(i)).OrderBy(i => i).ToArray();

            var cnt = 0;
            while(true){
                if(cnt < w.Length && l - w[cnt] >= 0){
                    l -= w[cnt];
                    cnt++;
                }else{
                    break;
                }
            }

            Console.WriteLine(cnt);
        }
    }
}
0