結果

問題 No.2387 Yokan Factory
ユーザー 👑 timitimi
提出日時 2024-02-14 11:37:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 891 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 263,308 KB
最終ジャッジ日時 2024-02-14 11:37:28
合計ジャッジ時間 13,134 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 38 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 39 ms
53,460 KB
testcase_06 AC 39 ms
53,460 KB
testcase_07 AC 38 ms
53,460 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 39 ms
53,460 KB
testcase_11 AC 39 ms
53,460 KB
testcase_12 AC 38 ms
53,460 KB
testcase_13 AC 38 ms
53,460 KB
testcase_14 AC 40 ms
53,460 KB
testcase_15 AC 2,616 ms
144,412 KB
testcase_16 AC 488 ms
118,284 KB
testcase_17 TLE -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 203 ms
82,368 KB
testcase_26 AC 194 ms
87,348 KB
testcase_27 AC 287 ms
90,012 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 93 ms
72,848 KB
testcase_36 WA -
testcase_37 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
def dijkstra(s,p):
    hq=[(0,s,0)]
    ans=[]
    heapq.heapify(hq) # リストを優先度付きキューに変換
    cost=[10**20]*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))

A=dijkstra(0,0)
if A[-1]>X:
  print(-1)
  exit()

ok,ng=0,10**18+1
while (ng-ok)>1:
  mid=(ok+ng)//2
  A=dijkstra(0,mid)
  if A[-1]>X:
    ng=mid
  else:
    ok=mid
print(ok)
0