結果

問題 No.5 数字のブロック
ユーザー swdamdr
提出日時 2017-01-24 10:36:30
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 547 bytes
コンパイル時間 882 ms
コンパイル使用メモリ 111,680 KB
実行使用メモリ 27,940 KB
最終ジャッジ日時 2024-11-18 10:51:29
合計ジャッジ時間 3,106 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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;

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 sum = 0;
        int i = 0;
        Array.Sort(array);

        for (; i < block; i++)
        {
            sum += array[i];

            if (sum > box)
            {
                break;
            }
        }

        Console.WriteLine(i);
    }
}
0