結果

問題 No.5 数字のブロック
ユーザー qwrtpsfg
提出日時 2017-08-06 19:49:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 40 ms / 5,000 ms
コード長 618 bytes
コンパイル時間 954 ms
コンパイル使用メモリ 115,628 KB
実行使用メモリ 28,052 KB
最終ジャッジ日時 2024-11-18 11:33:41
合計ジャッジ時間 2,919 ms
ジャッジサーバーID
(参考情報)
judge2 / 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;

public class Hello{
    public static void Main(){
        int length = int.Parse(Console.ReadLine().Trim());
        int n = int.Parse(Console.ReadLine().Trim());
        int[] blocks = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
        int answer = 0;
        
        Array.Sort(blocks);
        
        for(int i = 0; i < blocks.Length; i++)
        {
            length = length - blocks[i];
            if(length < 0)
            {
                break;
            }
            answer ++;
        }

        Console.WriteLine(answer);
    }
}
0