結果

問題 No.5 数字のブロック
ユーザー nachiguro1003
提出日時 2018-04-14 17:46:47
言語 Ruby
(3.4.1)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 319 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-11-18 12:16:18
合計ジャッジ時間 4,523 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

a=gets.chomp.to_i
b=gets.chomp.to_i
arr=gets.chomp.split(' ').map(&:to_i)
arr.sort!
sum = 0
ans = []
i = 0
    while sum < a
        sum += arr[i]
        ans << arr[i]
        i += 1
        break if i == b
    end
      x = ans.size.to_i
        if sum > a
          puts x-1
        else
          puts x
        end
0