結果

問題 No.1 道のショートカット
ユーザー yamaghyamagh
提出日時 2016-05-06 00:45:15
言語 Ruby
(3.3.0)
結果
RE  
実行時間 -
コード長 708 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 11,328 KB
実行使用メモリ 15,540 KB
最終ジャッジ日時 2023-09-22 12:43:22
合計ジャッジ時間 6,375 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,088 KB
testcase_01 AC 83 ms
15,084 KB
testcase_02 AC 83 ms
15,080 KB
testcase_03 AC 82 ms
15,312 KB
testcase_04 AC 81 ms
15,060 KB
testcase_05 AC 82 ms
15,156 KB
testcase_06 AC 81 ms
15,148 KB
testcase_07 AC 83 ms
15,216 KB
testcase_08 AC 90 ms
15,300 KB
testcase_09 AC 87 ms
15,468 KB
testcase_10 AC 85 ms
15,400 KB
testcase_11 AC 96 ms
15,416 KB
testcase_12 AC 93 ms
15,488 KB
testcase_13 AC 93 ms
15,488 KB
testcase_14 AC 80 ms
15,128 KB
testcase_15 RE -
testcase_16 WA -
testcase_17 RE -
testcase_18 AC 80 ms
15,208 KB
testcase_19 AC 81 ms
15,244 KB
testcase_20 AC 84 ms
15,208 KB
testcase_21 AC 84 ms
15,060 KB
testcase_22 AC 81 ms
15,040 KB
testcase_23 AC 117 ms
15,448 KB
testcase_24 AC 113 ms
15,524 KB
testcase_25 AC 88 ms
15,308 KB
testcase_26 AC 85 ms
15,312 KB
testcase_27 AC 108 ms
15,348 KB
testcase_28 RE -
testcase_29 AC 90 ms
15,464 KB
testcase_30 AC 85 ms
15,368 KB
testcase_31 AC 86 ms
15,320 KB
testcase_32 AC 85 ms
15,540 KB
testcase_33 AC 83 ms
15,220 KB
testcase_34 AC 97 ms
15,412 KB
testcase_35 AC 84 ms
15,472 KB
testcase_36 AC 84 ms
15,296 KB
testcase_37 AC 84 ms
15,136 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 82 ms
15,264 KB
testcase_41 WA -
testcase_42 RE -
testcase_43 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N=gets.to_i  # Nodes (2<=N<=50)
C=gets.to_i  # Costs (1<=C<=300)
V=gets.to_i  # Edges (1<=V<=1500)
S=gets.split.map{|m|m.to_i-1}  # FromTownNo
T=gets.split.map{|m|m.to_i-1}  # DestTownNo
Y=gets.split.map &:to_i        # Cost
M=gets.split.map &:to_i        # Time
MAX=999

tym=Array.new(S).map{Array.new(0)}
S.each.with_index{|e,i| tym[e] << { t: T[i], y:Y[i], m:M[i] }}

dp=Array.new(N).map{Array.new(C+1,MAX)}
dp[0][0]=0

N.times do |n|
  C.times do |c|
    next if dp[n][c]==MAX
    tym[n].each do |e|
      et=e[:t]
      ey=e[:y]+c
      next if C<ey
      em=e[:m]+dp[n][c]
      dp[et][ey]=[em, dp[et][ey]].min
    end
  end
end

#dp.each{|e|p e}

ans = [dp[N-1].min, MAX].min
puts ans==MAX ? -1 : ans
0