結果

問題 No.5 数字のブロック
ユーザー fungsi
提出日時 2025-09-09 18:39:26
言語 Crystal
(1.14.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 257 bytes
コンパイル時間 20,765 ms
コンパイル使用メモリ 310,324 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-09 18:39:49
合計ジャッジ時間 14,892 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

l = gets.not_nil!.to_i
n = gets.not_nil!.to_i
weights = [] of Int32
while weights.size < n
  weights.concat gets.not_nil!.split.map(&.to_i)
end

weights.sort!

sum = 0
count = 0

weights.each do |w|
  sum += w
  break if sum > l
  count += 1
end

puts count
0