結果

問題 No.5 数字のブロック
ユーザー kotowari_fkotowari_f
提出日時 2016-06-26 14:02:03
言語 Ruby
(3.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 359 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 11,252 KB
実行使用メモリ 15,612 KB
最終ジャッジ日時 2023-08-15 19:02:29
合計ジャッジ時間 5,312 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,140 KB
testcase_01 AC 80 ms
15,048 KB
testcase_02 AC 79 ms
15,060 KB
testcase_03 AC 86 ms
15,600 KB
testcase_04 AC 86 ms
15,468 KB
testcase_05 AC 88 ms
15,400 KB
testcase_06 AC 86 ms
15,516 KB
testcase_07 AC 84 ms
15,172 KB
testcase_08 AC 86 ms
15,496 KB
testcase_09 AC 83 ms
15,048 KB
testcase_10 AC 88 ms
15,484 KB
testcase_11 AC 85 ms
15,288 KB
testcase_12 AC 86 ms
15,312 KB
testcase_13 AC 87 ms
15,528 KB
testcase_14 AC 81 ms
15,048 KB
testcase_15 AC 81 ms
15,320 KB
testcase_16 AC 87 ms
15,384 KB
testcase_17 AC 90 ms
15,356 KB
testcase_18 AC 89 ms
15,300 KB
testcase_19 AC 91 ms
15,612 KB
testcase_20 AC 82 ms
15,248 KB
testcase_21 AC 81 ms
15,212 KB
testcase_22 AC 82 ms
15,076 KB
testcase_23 AC 83 ms
15,264 KB
testcase_24 AC 82 ms
15,272 KB
testcase_25 AC 82 ms
15,256 KB
testcase_26 AC 81 ms
15,328 KB
testcase_27 AC 81 ms
15,048 KB
testcase_28 AC 81 ms
15,052 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 79 ms
15,116 KB
testcase_32 AC 80 ms
15,080 KB
testcase_33 AC 81 ms
15,112 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:2: warning: assigned but unused variable - num
Syntax OK

ソースコード

diff #

big_w = gets.to_i 
num = gets.to_i 
n_w = gets.to_s 
n_w2 = n_w.split(" ") 

n_w2.map!(&:to_i)
i = 0
ans = 0
n_w2.sort.each_with_index do |a, index|
    if big_w >= n_w2.inject(:+)
        ans = n_w2.length
    elsif i + a == big_w
        ans = index + 1
    elsif i + a > big_w
        ans = index
        break
    else
        i += a
    end
end
puts ans
0