結果

問題 No.2387 Yokan Factory
ユーザー 👑 timitimi
提出日時 2024-02-14 12:12:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,217 bytes
コンパイル時間 2,157 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 267,652 KB
最終ジャッジ日時 2024-02-14 12:13:05
合計ジャッジ時間 38,652 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 38 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 39 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 37 ms
53,460 KB
testcase_10 AC 37 ms
53,456 KB
testcase_11 AC 37 ms
53,460 KB
testcase_12 AC 38 ms
53,460 KB
testcase_13 AC 38 ms
53,460 KB
testcase_14 AC 39 ms
53,460 KB
testcase_15 AC 3,725 ms
148,592 KB
testcase_16 AC 1,527 ms
144,728 KB
testcase_17 TLE -
testcase_18 AC 3,550 ms
146,224 KB
testcase_19 AC 3,344 ms
137,140 KB
testcase_20 AC 2,519 ms
115,476 KB
testcase_21 AC 4,931 ms
160,844 KB
testcase_22 AC 2,369 ms
113,540 KB
testcase_23 AC 3,705 ms
143,308 KB
testcase_24 AC 1,300 ms
108,868 KB
testcase_25 AC 252 ms
88,076 KB
testcase_26 AC 401 ms
98,940 KB
testcase_27 AC 479 ms
103,124 KB
testcase_28 AC 102 ms
76,596 KB
testcase_29 AC 123 ms
76,716 KB
testcase_30 AC 109 ms
76,456 KB
testcase_31 AC 98 ms
76,088 KB
testcase_32 AC 87 ms
75,976 KB
testcase_33 AC 81 ms
75,720 KB
testcase_34 AC 111 ms
76,468 KB
testcase_35 AC 67 ms
70,668 KB
testcase_36 AC 80 ms
74,188 KB
testcase_37 AC 39 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  from sys import stdin, setrecursionlimit
  input = stdin.readline
  readline = stdin.readline
 
  import heapq
  def dijkstra(s,p):
      hq=[(0,s,0)]
      heapq.heapify(hq) # リストを優先度付きキューに変換
      cost=[10**18+1]*N # 行ったことのないところはinf
      cost[s]=0 # 開始地点は0
      while hq:
        c,v,pre=heapq.heappop(hq)
        if c>cost[v]: # コストが現在のコストよりも高ければスルー v:now u:nex
          continue
        for d,u,pp in E[v]:
          if p>pp:
            continue
          tmp=d+cost[v]
          if tmp<cost[u]:
            cost[u]=tmp
            heapq.heappush(hq,(tmp,u,v))
      return cost
  
  N,M,X=map(int,input().split())
  E=[[] for _ in range(N)]
  for i in range(M):
    a,b,t,x=map(int,input().split())
    a-=1;b-=1
    E[a].append((t,b,x))
    E[b].append((t,a,x))
  for i in range(N):
    E[i]=sorted(E[i][::-1])
  
  A=dijkstra(0,0)
  if A[-1]>X:
    print(-1)
    exit()
  A=dijkstra(0,10**9)
  if A[-1]<=X:
    print(10**9)
    exit()
  
  ok,ng=0,10**9+1
  while (ng-ok)>1:
    mid=(ok+ng)//2
    A=dijkstra(0,mid)
    if A[-1]>X:
      ng=mid
    else:
      ok=mid
  print(ok)
main()
0