結果

問題 No.617 Nafmo、買い出しに行く
ユーザー maimai
提出日時 2017-12-17 00:14:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 476 ms / 2,000 ms
コード長 217 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-05-08 17:02:08
合計ジャッジ時間 7,065 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
12,032 KB
testcase_01 AC 85 ms
12,032 KB
testcase_02 AC 86 ms
12,160 KB
testcase_03 AC 115 ms
13,440 KB
testcase_04 AC 91 ms
12,032 KB
testcase_05 AC 138 ms
13,312 KB
testcase_06 AC 476 ms
13,568 KB
testcase_07 AC 474 ms
13,568 KB
testcase_08 AC 88 ms
12,032 KB
testcase_09 AC 87 ms
12,032 KB
testcase_10 AC 470 ms
13,568 KB
testcase_11 AC 471 ms
13,568 KB
testcase_12 AC 472 ms
13,568 KB
testcase_13 AC 476 ms
13,568 KB
testcase_14 AC 475 ms
13,568 KB
testcase_15 AC 454 ms
13,440 KB
testcase_16 AC 456 ms
13,440 KB
testcase_17 AC 453 ms
13,568 KB
testcase_18 AC 89 ms
12,160 KB
testcase_19 AC 92 ms
12,032 KB
testcase_20 AC 90 ms
12,160 KB
testcase_21 AC 88 ms
12,160 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