結果

問題 No.617 Nafmo、買い出しに行く
ユーザー maimai
提出日時 2017-12-17 00:14:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 474 ms / 2,000 ms
コード長 217 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 11,236 KB
実行使用メモリ 17,288 KB
最終ジャッジ日時 2023-08-21 11:41:22
合計ジャッジ時間 6,713 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,300 KB
testcase_01 AC 77 ms
15,220 KB
testcase_02 AC 78 ms
15,296 KB
testcase_03 AC 103 ms
17,056 KB
testcase_04 AC 78 ms
15,344 KB
testcase_05 AC 131 ms
17,156 KB
testcase_06 AC 473 ms
17,104 KB
testcase_07 AC 473 ms
17,176 KB
testcase_08 AC 78 ms
15,072 KB
testcase_09 AC 77 ms
15,116 KB
testcase_10 AC 474 ms
17,288 KB
testcase_11 AC 472 ms
17,176 KB
testcase_12 AC 473 ms
17,148 KB
testcase_13 AC 471 ms
17,152 KB
testcase_14 AC 473 ms
17,100 KB
testcase_15 AC 453 ms
17,200 KB
testcase_16 AC 454 ms
17,152 KB
testcase_17 AC 461 ms
17,256 KB
testcase_18 AC 81 ms
15,268 KB
testcase_19 AC 77 ms
15,288 KB
testcase_20 AC 77 ms
15,116 KB
testcase_21 AC 77 ms
15,284 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def ascan; gets.split.map(&:to_i);end

n, k = ascan
aa = (1..n).map{gets.to_i}

ans = 0
(1..n).each do |m|
    aa.combination(m) do |cb|
        w = cb.reduce(:+)
        ans = [w,ans].max if w <= k
    end
end

p ans
0