結果

問題 No.914 Omiyage
ユーザー _Iruk__Iruk_
提出日時 2019-10-26 16:23:15
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 420 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 11,288 KB
実行使用メモリ 15,396 KB
最終ジャッジ日時 2023-10-12 13:23:22
合計ジャッジ時間 2,771 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,076 KB
testcase_01 AC 84 ms
15,128 KB
testcase_02 WA -
testcase_03 AC 83 ms
15,268 KB
testcase_04 AC 79 ms
15,088 KB
testcase_05 WA -
testcase_06 AC 81 ms
15,308 KB
testcase_07 WA -
testcase_08 AC 82 ms
15,112 KB
testcase_09 AC 81 ms
15,124 KB
testcase_10 AC 80 ms
15,324 KB
testcase_11 AC 81 ms
15,092 KB
testcase_12 AC 82 ms
15,328 KB
testcase_13 AC 81 ms
15,132 KB
testcase_14 AC 82 ms
15,264 KB
testcase_15 AC 80 ms
15,084 KB
testcase_16 AC 79 ms
15,128 KB
testcase_17 AC 81 ms
15,120 KB
testcase_18 AC 81 ms
15,240 KB
testcase_19 AC 80 ms
15,052 KB
testcase_20 AC 80 ms
15,268 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

a = gets.split.map(&:to_i)
b = []
a[0].times do
  b << gets.split.map(&:to_i)
end

memo = [b.first]
a[0].times do |n|
  memo.last.uniq!
  tmp = []
  a[1].times do |m|
    break unless b[n+1]
    memo.last.length.times do |l|
      sum = memo[n][l] + b[n+1][m]
      sum <= a[2] ? tmp << sum : next
    end
  end
  memo << tmp
end

memo.each {|n| memo.delete(n) if n.empty?}

p memo.count == 1 ? -1 : a[2] - memo.last.max
0