結果

問題 No.5 数字のブロック
ユーザー oldlevin
提出日時 2020-03-04 16:53:25
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 698 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 110,588 KB
実行使用メモリ 29,456 KB
最終ジャッジ日時 2024-10-14 00:19:27
合計ジャッジ時間 3,222 ms
ジャッジサーバーID
(参考情報)
judge4 / 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;
        long sum =0;
        for(int i=0;i<len;i++){
           sum += s[count++];
           if(sum > w ) break;
        }
        WriteLine(count-1);
        //WriteLine(string.Join(" ",s));
    }
}
0