結果

問題 No.5 数字のブロック
ユーザー tshigtshig
提出日時 2016-08-02 17:02:33
言語 Ruby
(3.3.0)
結果
AC  
実行時間 94 ms / 5,000 ms
コード長 368 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 11,404 KB
実行使用メモリ 16,424 KB
最終ジャッジ日時 2023-08-11 15:19:40
合計ジャッジ時間 5,195 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,164 KB
testcase_01 AC 83 ms
15,176 KB
testcase_02 AC 81 ms
15,148 KB
testcase_03 AC 88 ms
15,672 KB
testcase_04 AC 85 ms
15,600 KB
testcase_05 AC 89 ms
15,904 KB
testcase_06 AC 85 ms
15,612 KB
testcase_07 AC 85 ms
15,576 KB
testcase_08 AC 86 ms
16,068 KB
testcase_09 AC 83 ms
15,436 KB
testcase_10 AC 92 ms
16,104 KB
testcase_11 AC 86 ms
15,328 KB
testcase_12 AC 88 ms
16,108 KB
testcase_13 AC 90 ms
15,864 KB
testcase_14 AC 80 ms
15,128 KB
testcase_15 AC 80 ms
15,060 KB
testcase_16 AC 89 ms
16,124 KB
testcase_17 AC 91 ms
16,172 KB
testcase_18 AC 92 ms
16,064 KB
testcase_19 AC 94 ms
16,424 KB
testcase_20 AC 81 ms
15,148 KB
testcase_21 AC 81 ms
15,036 KB
testcase_22 AC 81 ms
15,208 KB
testcase_23 AC 81 ms
15,312 KB
testcase_24 AC 82 ms
15,260 KB
testcase_25 AC 83 ms
15,236 KB
testcase_26 AC 82 ms
15,072 KB
testcase_27 AC 81 ms
15,080 KB
testcase_28 AC 81 ms
15,072 KB
testcase_29 AC 87 ms
15,584 KB
testcase_30 AC 85 ms
15,584 KB
testcase_31 AC 81 ms
15,272 KB
testcase_32 AC 83 ms
15,252 KB
testcase_33 AC 82 ms
15,164 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Calc0005
  def initialize(args)
    args = args.map { |l| l.chomp.split(/\s+/) }
    @l = args.shift.first.to_i
    @n = args.shift.first.to_i
    @ws = args.shift.map(&:to_i)
  end

  def run
    s = c = 0
    @ws.sort.each do |w|
      s += w
      break if s > @l
      c += 1
    end
    c
  end
end

puts Calc0005.new(STDIN.readlines).run if __FILE__ == $0
0