結果

問題 No.5 数字のブロック
ユーザー vjudge1
提出日時 2025-09-04 09:37:31
言語 Crystal
(1.14.0)
結果
RE  
実行時間 -
コード長 277 bytes
コンパイル時間 14,293 ms
コンパイル使用メモリ 311,552 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-04 09:37:47
合計ジャッジ時間 15,160 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

# Read input
k, n = gets.not_nil!.split.map(&.to_i)

# Read array of n integers
a = Array(Int32).new(n)
n.times do |i|
  a[i] = gets.not_nil!.to_i
end

# Sort the array
a.sort!

# Process elements
(0...n).each do |i|
  k -= a[i]
  if k < 0
    puts i
    exit
  end
end

puts n
0