結果

問題 No.914 Omiyage
ユーザー startcppstartcpp
提出日時 2019-10-26 16:49:09
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 452 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 11,204 KB
実行使用メモリ 15,352 KB
最終ジャッジ日時 2023-10-12 14:27:21
合計ジャッジ時間 3,839 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,312 KB
testcase_01 AC 81 ms
15,040 KB
testcase_02 AC 79 ms
15,216 KB
testcase_03 AC 81 ms
15,352 KB
testcase_04 AC 81 ms
15,128 KB
testcase_05 AC 78 ms
15,284 KB
testcase_06 AC 77 ms
15,276 KB
testcase_07 AC 77 ms
15,284 KB
testcase_08 AC 78 ms
15,092 KB
testcase_09 WA -
testcase_10 AC 79 ms
15,040 KB
testcase_11 AC 78 ms
15,144 KB
testcase_12 AC 78 ms
15,096 KB
testcase_13 AC 80 ms
15,140 KB
testcase_14 AC 81 ms
15,352 KB
testcase_15 AC 78 ms
15,256 KB
testcase_16 AC 79 ms
15,040 KB
testcase_17 AC 79 ms
15,260 KB
testcase_18 AC 78 ms
15,132 KB
testcase_19 AC 80 ms
15,176 KB
testcase_20 AC 77 ms
15,252 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] - 1).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