結果

問題 No.617 Nafmo、買い出しに行く
ユーザー Takuya NoguchiTakuya Noguchi
提出日時 2018-01-14 18:54:29
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 272 bytes
コンパイル時間 61 ms
コンパイル使用メモリ 11,572 KB
実行使用メモリ 74,476 KB
最終ジャッジ日時 2023-08-25 17:30:16
合計ジャッジ時間 8,599 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
15,260 KB
testcase_01 AC 70 ms
15,140 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 74 ms
15,280 KB
testcase_06 AC 79 ms
15,268 KB
testcase_07 AC 71 ms
15,052 KB
testcase_08 AC 70 ms
15,044 KB
testcase_09 AC 76 ms
15,268 KB
testcase_10 AC 71 ms
15,020 KB
testcase_11 AC 70 ms
15,056 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1,870 ms
74,476 KB
testcase_16 AC 1,937 ms
74,368 KB
testcase_17 AC 1,921 ms
74,392 KB
testcase_18 AC 71 ms
15,136 KB
testcase_19 AC 71 ms
15,284 KB
testcase_20 AC 69 ms
15,156 KB
testcase_21 AC 73 ms
15,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

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

  break unless max.zero?
end

puts max
0