結果

問題 No.1 道のショートカット
ユーザー gigurururu
提出日時 2014-11-04 15:24:24
言語 Python2
(2.7.18)
結果
AC  
実行時間 94 ms / 5,000 ms
コード長 292 bytes
コンパイル時間 686 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-07-20 16:06:07
合計ジャッジ時間 2,609 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

n=input()
c=input()
input()
l=[dict() for _ in range(n+1)]
l[1][0]=0
for s,t,y,m in sorted(zip(*[map(int,raw_input().split()) for _ in range(4)])):
    for k,v in l[s].iteritems():
        if k+y<=c: l[t][k+y]=min(l[t].get(k+y,1e9),v+m)
print min(l[n].values()) if len(l[n])>0 else -1
0