結果

問題 No.617 Nafmo、買い出しに行く
ユーザー nonokai10nonokai10
提出日時 2018-03-12 17:05:45
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 263 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 19,616 KB
最終ジャッジ日時 2024-04-25 15:14:51
合計ジャッジ時間 6,031 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
19,232 KB
testcase_01 AC 82 ms
12,160 KB
testcase_02 AC 98 ms
12,416 KB
testcase_03 AC 610 ms
12,288 KB
testcase_04 AC 81 ms
12,288 KB
testcase_05 AC 1,181 ms
12,416 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, k, *a = gets.split.map(&:to_i)
n.times do
  a << gets.to_i
end
max = 0
(0..2**n-1).each do |i|
  b = a.zip(i.to_s(2).rjust(n,'0').split(//).map(&:to_i))
  sum = 0
  b.each do |j|
    sum += j[0] if j[1] == 1
  end
  max = sum if sum > max && sum <= k
end
p max
0