結果

問題 No.5 数字のブロック
ユーザー monpe
提出日時 2021-09-23 20:16:13
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 604 bytes
コンパイル時間 922 ms
コンパイル使用メモリ 104,448 KB
実行使用メモリ 20,352 KB
最終ジャッジ日時 2024-07-05 09:29:40
合計ジャッジ時間 2,949 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
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()
    {
        var box = int.Parse(Console.ReadLine());
        int N = int.Parse(Console.ReadLine());
        var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        Array.Sort(line);
        int ans = 0;
        int count = 0;
        for(int i = 0; i < N; i++)
        {
            if(ans <= box)
            {
                ans += line[i];
                count++;
            }
            else
            {
                break;
            }
        }
        Console.WriteLine(count -1);
    }
}
0