結果

問題 No.5 数字のブロック
ユーザー apierce
提出日時 2022-10-29 19:35:28
言語 Ruby
(3.4.1)
結果
RE  
実行時間 -
コード長 197 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,672 KB
最終ジャッジ日時 2024-07-06 16:42:24
合計ジャッジ時間 3,792 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 RE * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

mx = gets.to_i
n = gets.to_i
a = gets.split.map(&:to_i).sort
cnt = 0
while mx >= 0
    v = a.shift
    if v <= mx
        cnt += 1
        mx -= v
    else
        puts cnt
        exit
    end
end
0