結果

問題 No.5 数字のブロック
ユーザー kotowari_fkotowari_f
提出日時 2016-06-20 21:32:20
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 996 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-04-19 23:18:25
合計ジャッジ時間 5,382 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
12,032 KB
testcase_01 AC 97 ms
12,160 KB
testcase_02 WA -
testcase_03 AC 99 ms
12,288 KB
testcase_04 AC 105 ms
12,160 KB
testcase_05 WA -
testcase_06 AC 100 ms
12,416 KB
testcase_07 AC 99 ms
12,032 KB
testcase_08 AC 102 ms
12,416 KB
testcase_09 AC 99 ms
12,288 KB
testcase_10 AC 99 ms
12,416 KB
testcase_11 AC 99 ms
12,160 KB
testcase_12 AC 102 ms
12,288 KB
testcase_13 AC 101 ms
12,160 KB
testcase_14 AC 95 ms
12,160 KB
testcase_15 WA -
testcase_16 AC 102 ms
12,544 KB
testcase_17 AC 103 ms
12,288 KB
testcase_18 AC 101 ms
12,288 KB
testcase_19 AC 99 ms
12,416 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 96 ms
12,032 KB
testcase_24 AC 100 ms
12,032 KB
testcase_25 AC 96 ms
12,160 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# yukicoder
# No.5 数字のブロック
# 数字が書かれているブロックはそれぞれ高さ1で幅はWiである。
# それらのブロックを高さ1,幅Lの大きな箱の中に入れる。

# 入力)
# 16    大きな箱の幅を表すL(1≤L≤10000)L(1≤L≤10000)
# 3     ブロックの数を表すN(1≤N≤10000)N(1≤N≤10000)
# 10 5 7    各ブロックの幅を表すWi(1≤Wi≤L)Wi(1≤Wi≤L)が半角スペース区切り

# 出力)
# 2

big_w = gets.to_i #大きな箱の幅
num = gets.to_i #ブロックの数
n_w = gets.to_s #各ブロックの幅
n_w2 = n_w.split(" ") #スペース区切りの文字列から、空白を除いて配列に入れる

if num <= n_w2.length
    n_w2.slice!(num..n_w2.length) #ブロックの個数を合わせる
end

n_w2.map!(&:to_i)   #文字列から数値に変換

i = 0
ans = 0
n_w2.sort.each_with_index do |a, index|
    if i + a >= big_w
        ans = index
        break
    else
        i += a
    end
end
puts ans
0