結果

問題 No.617 Nafmo、買い出しに行く
ユーザー nonokai10nonokai10
提出日時 2018-03-28 21:52:47
言語 Ruby
(3.3.0)
結果
AC  
実行時間 474 ms / 2,000 ms
コード長 191 bytes
コンパイル時間 353 ms
コンパイル使用メモリ 11,272 KB
実行使用メモリ 33,748 KB
最終ジャッジ日時 2023-09-07 19:32:13
合計ジャッジ時間 7,654 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
15,312 KB
testcase_01 AC 84 ms
15,148 KB
testcase_02 AC 87 ms
15,276 KB
testcase_03 AC 113 ms
18,540 KB
testcase_04 AC 86 ms
15,080 KB
testcase_05 AC 135 ms
19,512 KB
testcase_06 AC 474 ms
33,740 KB
testcase_07 AC 471 ms
33,748 KB
testcase_08 AC 86 ms
15,168 KB
testcase_09 AC 87 ms
15,152 KB
testcase_10 AC 461 ms
33,492 KB
testcase_11 AC 469 ms
33,656 KB
testcase_12 AC 465 ms
33,700 KB
testcase_13 AC 469 ms
32,180 KB
testcase_14 AC 468 ms
33,576 KB
testcase_15 AC 458 ms
25,560 KB
testcase_16 AC 444 ms
25,500 KB
testcase_17 AC 451 ms
25,468 KB
testcase_18 AC 87 ms
15,128 KB
testcase_19 AC 85 ms
15,272 KB
testcase_20 AC 87 ms
15,224 KB
testcase_21 AC 85 ms
15,224 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, k = gets.split.map(&:to_i)
a = []
n.times do
  a << gets.to_i
end
b = []
(1..n).each do |i|
  a.combination(i).each do |x|
    b << x.sum
  end
end
p (x = b.select{|i| i <= k}.max) ? x : 0
0