結果

問題 No.617 Nafmo、買い出しに行く
ユーザー Takuya NoguchiTakuya Noguchi
提出日時 2018-01-14 18:49:15
言語 Ruby
(3.3.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 246 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 11,572 KB
実行使用メモリ 78,852 KB
最終ジャッジ日時 2023-08-25 17:29:59
合計ジャッジ時間 7,877 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,292 KB
testcase_01 AC 83 ms
14,996 KB
testcase_02 AC 84 ms
15,240 KB
testcase_03 AC 180 ms
18,640 KB
testcase_04 AC 85 ms
15,208 KB
testcase_05 AC 302 ms
26,608 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 85 ms
15,248 KB
testcase_09 AC 83 ms
15,212 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,000 KB
testcase_19 AC 82 ms
15,288 KB
testcase_20 AC 83 ms
15,292 KB
testcase_21 AC 82 ms
15,108 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

_, K = gets.split.map(&:to_i)

max = 0
A = readlines.map(&:to_i)
(1..A.length).each do |n|
  max = [
    (A.combination(n).to_a.map { |ary|
       ary.inject(0, &:+)
     }.reject { |a|
       a > K
     }.max || 0),
    max
  ].max
end

puts max
0