結果

問題 No.2387 Yokan Factory
ユーザー miho-4miho-4
提出日時 2023-07-22 00:01:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 634 bytes
コンパイル時間 1,396 ms
コンパイル使用メモリ 81,604 KB
実行使用メモリ 254,272 KB
最終ジャッジ日時 2023-10-21 23:58:48
合計ジャッジ時間 21,033 ms
ジャッジサーバーID
(参考情報)
judge13 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 40 ms
53,492 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 39 ms
53,492 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 40 ms
53,492 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 40 ms
53,492 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 183 ms
96,044 KB
testcase_26 AC 414 ms
114,308 KB
testcase_27 AC 430 ms
121,356 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 161 ms
77,612 KB
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

n,m,X=map(int,input().split())
edge=[tuple(map(int,input().split())) for _ in range(m)]

E=[[] for _ in range(n+1)]
for u,v,a,b in edge:
  E[u].append((v,a,b))
  E[v].append((u,a,b))
  
for i in range(n+1):
  E[i].sort(key=lambda x:x[2],reverse=True)

def f(w):
  D=[10**19]*(n+1)
  D[1]=0
  q=[]
  heapq.heappush(q,(0,1))
  while q:
    d,x=heapq.heappop(q)
    if x==n:break
    for e,a,b in E[x]:
      if w<b:break
      if D[x]+a<D[e]:
        D[e]=D[x]+a
        heapq.heappush(q,(d+a,e))

  return 0<D[-1]<=X

l,r=-1,10**9+10
while l+1<r:
  m=(l+r)//2
  flag=f(m)

  if flag:
    l=m
  else:
    r=m
    
print(l)
0