結果

問題 No.5 数字のブロック
ユーザー oldlevinoldlevin
提出日時 2020-03-04 16:43:15
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 852 ms
コンパイル使用メモリ 107,584 KB
実行使用メモリ 27,292 KB
最終ジャッジ日時 2024-10-14 00:19:04
合計ジャッジ時間 3,063 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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;
using System.Collections.Generic;
using static System.Console;


public class Hello{
    public static void Main(){
        //yukicoder No.5 数字のブロック 最大何個入れられるか しゃくとり法
        
        var w = int.Parse(ReadLine().Trim());
        var n = int.Parse(ReadLine().Trim());
        var s = ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
        var len =  s.Length;
        Array.Sort(s);
        var count =0;
        var sum =0;
        for(int i=0;i<len;i++){
           sum += s[count++];
           if(sum > w ) break;
        }
        WriteLine(count-1);
        //WriteLine(string.Join(" ",s));
    }
}
0