結果

問題 No.5 数字のブロック
ユーザー swdamdr
提出日時 2017-01-24 10:32:56
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 621 bytes
コンパイル時間 1,020 ms
コンパイル使用メモリ 108,620 KB
実行使用メモリ 29,860 KB
最終ジャッジ日時 2024-12-23 07:47:55
合計ジャッジ時間 3,435 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

class Program
{
    static void Main(string[] args)
    {
        int box = int.Parse(Console.ReadLine());
        int block = int.Parse(Console.ReadLine());
        int[] array = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int width = 0;
        int i;
        Array.Sort(array);

        for (i = 0; i < array.Length; i++)
        {
            if (width + array[i] >= box)
            {
                break;
            }
            else
            {
                width += array[i];
            }
        }

        Console.WriteLine(i);
    }
}
0