結果

問題 No.914 Omiyage
ユーザー _Iruk__Iruk_
提出日時 2019-10-26 16:25:11
言語 Ruby
(3.2.2)
結果
WA  
実行時間 -
コード長 460 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 11,548 KB
実行使用メモリ 15,412 KB
最終ジャッジ日時 2023-10-12 13:26:18
合計ジャッジ時間 3,274 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 80 ms
15,260 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 81 ms
15,304 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 80 ms
15,176 KB
testcase_20 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:22: warning: ambiguous first argument; put parentheses or a space even after `-' operator
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

if memo.last.empty?
  p -1
else
  memo.each {|n| memo.delete(n) if n.empty?}
  p memo.count == 1 ? -1 : a[2] - memo.last.max
end
0