結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,268 KB
testcase_01 AC 80 ms
15,248 KB
testcase_02 AC 80 ms
15,020 KB
testcase_03 AC 83 ms
15,364 KB
testcase_04 AC 79 ms
15,288 KB
testcase_05 AC 80 ms
15,116 KB
testcase_06 AC 81 ms
15,228 KB
testcase_07 AC 80 ms
15,112 KB
testcase_08 AC 78 ms
15,012 KB
testcase_09 WA -
testcase_10 AC 78 ms
15,140 KB
testcase_11 AC 78 ms
15,032 KB
testcase_12 AC 79 ms
15,228 KB
testcase_13 AC 79 ms
15,140 KB
testcase_14 AC 81 ms
15,120 KB
testcase_15 AC 79 ms
15,112 KB
testcase_16 AC 79 ms
15,224 KB
testcase_17 AC 80 ms
15,112 KB
testcase_18 AC 78 ms
15,032 KB
testcase_19 AC 80 ms
15,020 KB
testcase_20 AC 79 ms
15,024 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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

init_memo = b.first

memo = [init_memo]
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 == a[0] ?  a[2] - memo.last.max : -1
0