結果

問題 No.1 道のショートカット
ユーザー らっしー(raccy)らっしー(raccy)
提出日時 2014-12-07 19:29:23
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 885 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 11,380 KB
実行使用メモリ 15,568 KB
最終ジャッジ日時 2023-09-22 11:48:58
合計ジャッジ時間 6,364 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,304 KB
testcase_01 AC 78 ms
15,124 KB
testcase_02 AC 81 ms
15,288 KB
testcase_03 RE -
testcase_04 AC 78 ms
15,272 KB
testcase_05 AC 78 ms
15,256 KB
testcase_06 RE -
testcase_07 AC 78 ms
15,236 KB
testcase_08 AC 86 ms
15,532 KB
testcase_09 AC 83 ms
15,132 KB
testcase_10 AC 84 ms
15,180 KB
testcase_11 AC 98 ms
15,388 KB
testcase_12 AC 111 ms
15,456 KB
testcase_13 AC 106 ms
15,568 KB
testcase_14 AC 79 ms
15,272 KB
testcase_15 RE -
testcase_16 AC 80 ms
15,260 KB
testcase_17 RE -
testcase_18 AC 78 ms
15,148 KB
testcase_19 AC 78 ms
15,296 KB
testcase_20 AC 82 ms
15,272 KB
testcase_21 AC 80 ms
15,000 KB
testcase_22 AC 79 ms
15,280 KB
testcase_23 AC 127 ms
15,412 KB
testcase_24 AC 125 ms
15,408 KB
testcase_25 AC 87 ms
15,188 KB
testcase_26 AC 82 ms
15,180 KB
testcase_27 AC 119 ms
15,380 KB
testcase_28 AC 79 ms
14,996 KB
testcase_29 AC 90 ms
15,392 KB
testcase_30 AC 83 ms
15,144 KB
testcase_31 AC 89 ms
15,036 KB
testcase_32 AC 90 ms
15,424 KB
testcase_33 AC 85 ms
15,292 KB
testcase_34 AC 116 ms
15,356 KB
testcase_35 AC 80 ms
15,192 KB
testcase_36 AC 82 ms
15,272 KB
testcase_37 AC 80 ms
15,052 KB
testcase_38 AC 76 ms
15,144 KB
testcase_39 AC 79 ms
15,040 KB
testcase_40 AC 79 ms
15,144 KB
testcase_41 AC 78 ms
14,996 KB
testcase_42 AC 76 ms
15,096 KB
testcase_43 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
c = gets.to_i
v = gets.to_i
s = gets.split.map(&:to_i)
t = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)
m = gets.split.map(&:to_i)

list = []
v.times do |i|
  list << [s[i], t[i], y[i], m[i]]
end
list.sort!{|a, b| a[0] <=> b[0]}

all_pats = {}
all_pats[1] = {c => 0}
list.each do |keiro|
  if all_pats[keiro[0]]
    all_pats[keiro[0]].each do |coin, time|
      nokori = coin - keiro[2]
      if nokori >= 0
        if all_pats[keiro[1]].nil?
          all_pats[keiro[1]] = {}
        end
        if all_pats[keiro[1]][nokori].nil? ||
            all_pats[keiro[1]][nokori] > (time + keiro[3])
          all_pats[keiro[1]][nokori] = time + keiro[3]
        end
      end
    end
  end
end

min_time = nil
all_pats[n].each do |coin, time|
  if min_time.nil? || min_time > time
    min_time = time
  end
end
puts min_time || -1
0