結果

問題 No.3013 ハチマキ買い星人
ユーザー こめだわら
提出日時 2025-01-07 21:26:08
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 601 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 82,708 KB
実行使用メモリ 201,456 KB
最終ジャッジ日時 2025-01-25 21:57:30
合計ジャッジ時間 3,539 ms
ジャッジサーバーID
(参考情報)
judge8 / judge10
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 TLE * 2 -- * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#嘘ダイクストラ

N,M,P,Y=map(int,input().split())
edge=[[] for _ in range(N)]
for _ in range(M):
    a,b,c=map(int,input().split())
    a-=1
    b-=1
    edge[a].append((b,c))
    edge[b].append((a,c))

from heapq import *

D=[10**18]*N
D[0]=0
H=[(0,0)]
while H:
    cd,cp=heappop(H)
    # こいつが必要だよ!
    # if D[cp]<cd:
    #     continue
    for np,dd in edge[cp]:
        nd=cd+dd
        if D[np]>nd:
            D[np]=nd
            heappush(H,(nd,np))

ans=0
for _ in range(P):
    d,e=map(int,input().split())
    d-=1
    rest=Y-D[d]
    ans=max(ans,rest//e)

print(ans)
0