結果

問題 No.1 道のショートカット
ユーザー Snark86
提出日時 2016-04-27 01:30:23
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 671 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 27,036 KB
最終ジャッジ日時 2024-07-08 04:27:20
合計ジャッジ時間 8,490 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 2 TLE * 1 -- * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(raw_input())
c = int(raw_input())
v = int(raw_input())
s = map(int, raw_input().split())
t = map(int, raw_input().split())
y = map(int, raw_input().split())
m = map(int, raw_input().split())

a = [[c,0,0]]
b = [[] for _ in range(n-1)]
d = [[] for _ in range(n-1)]
for i in range(v):
	b[s[i]-1].append([y[i],m[i],t[i]-1])
ans = []
while a:
	ac,at,ap = a.pop()
	for bi in b[ap]:
		bc,bt,bp = bi
		if ac >= bc:
			if bp == n-1:
				ans.append([ac-bc,at+bt])
			else:
				for dc,dt in d[bp]:
					if ac-bc >= dc and at+bt >= dt: break
				else:
					d[bp].append([ac-bc,at+bt])
					a.append([ac-bc,at+bt,bp])

print sorted(ans,key=lambda x:x[1])[0][1] if ans else -1
0