結果

問題 No.156 キャンディー・ボックス
ユーザー mesh1nek0x0mesh1nek0x0
提出日時 2018-07-21 23:25:27
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 257 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 11,232 KB
実行使用メモリ 15,364 KB
最終ジャッジ日時 2023-08-27 00:47:59
合計ジャッジ時間 4,736 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 72 ms
15,112 KB
testcase_02 AC 75 ms
15,132 KB
testcase_03 AC 78 ms
15,100 KB
testcase_04 AC 74 ms
15,212 KB
testcase_05 AC 74 ms
15,024 KB
testcase_06 AC 73 ms
15,256 KB
testcase_07 AC 75 ms
15,132 KB
testcase_08 AC 74 ms
15,164 KB
testcase_09 AC 73 ms
15,136 KB
testcase_10 AC 74 ms
15,248 KB
testcase_11 AC 73 ms
15,164 KB
testcase_12 AC 75 ms
15,256 KB
testcase_13 AC 76 ms
15,136 KB
testcase_14 AC 79 ms
15,156 KB
testcase_15 AC 77 ms
15,160 KB
testcase_16 AC 81 ms
15,164 KB
testcase_17 AC 79 ms
15,332 KB
testcase_18 WA -
testcase_19 AC 78 ms
15,304 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 75 ms
15,184 KB
testcase_23 WA -
testcase_24 AC 77 ms
15,216 KB
testcase_25 AC 74 ms
15,292 KB
testcase_26 AC 78 ms
15,312 KB
testcase_27 AC 75 ms
15,140 KB
testcase_28 AC 75 ms
15,352 KB
testcase_29 AC 74 ms
15,140 KB
testcase_30 AC 74 ms
15,248 KB
testcase_31 AC 74 ms
15,300 KB
testcase_32 AC 77 ms
15,136 KB
testcase_33 AC 74 ms
15,208 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!/bin/ruby
input = gets.chomp.split(' ')
N = input[0].to_i
M = input[1].to_i

c = gets.chomp.split(' ').sort

sum = 0
box = 0
c.each { |num|
  sum += num.to_i
  if sum > M
    break
  end
  if sum === M
    box += 1
    break
  end
  box += 1
}

puts box

0