結果

問題 No.617 Nafmo、買い出しに行く
ユーザー finefine
提出日時 2017-12-17 16:27:49
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 241 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 11,320 KB
実行使用メモリ 15,336 KB
最終ジャッジ日時 2023-08-22 04:34:20
合計ジャッジ時間 27,434 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,216 KB
testcase_01 AC 82 ms
15,196 KB
testcase_02 AC 85 ms
15,088 KB
testcase_03 AC 199 ms
15,028 KB
testcase_04 AC 81 ms
15,076 KB
testcase_05 AC 331 ms
14,916 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 83 ms
15,124 KB
testcase_09 AC 81 ms
15,216 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 82 ms
15,076 KB
testcase_19 AC 82 ms
15,032 KB
testcase_20 AC 82 ms
15,176 KB
testcase_21 AC 82 ms
15,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n,k=gets.split.map(&:to_i)
a=$<.map(&:to_i)
ans = 0
(1 << n).times do |i|
    sum = 0
    n.times do |j|
        if (i & (1 << j)) > 0
            sum += a[j]
        end
    end
    if sum <= k
        ans = [ans, sum].max
    end
end
p ans
0