結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-14 21:03:10 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 125 ms / 5,000 ms |
| コード長 | 244 bytes |
| コンパイル時間 | 178 ms |
| コンパイル使用メモリ | 8,192 KB |
| 実行使用メモリ | 13,184 KB |
| 最終ジャッジ日時 | 2025-10-14 21:03:17 |
| 合計ジャッジ時間 | 6,384 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
コンパイルメッセージ
Syntax OK
ソースコード
N,C,V=3.times.map{gets.to_i}
dp=Array.new(N+1){Array.new(C+1,10**9+7)}
dp[1][0]=0
4.times.map{gets.split.map(&:to_i)}.transpose.sort.map{|s,t,y,m|
y.upto(C){|j| dp[t][j]=[dp[s][j-y]+m,dp[t][j]].min}
}
ans=dp[N].min
ans=-1 if ans==10**9+7
p ans