結果
問題 | No.3013 ハチマキ買い星人 |
ユーザー |
![]() |
提出日時 | 2025-02-01 05:04:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,097 ms / 2,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 1,152 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 116,248 KB |
最終ジャッジ日時 | 2025-02-01 05:05:20 |
合計ジャッジ時間 | 27,224 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 |
ソースコード
N,M,P,Y=map(int,input().split())E=[[] for i in range(N)]for i in range(M):a,b,c=map(int,input().split())a-=1b-=1E[a].append((b,c))E[b].append((a,c))LIST=[1<<60]*Nfor i in range(P):d,e=map(int,input().split())LIST[d-1]=efrom heapq import heappop,heappushDIS=[1<<60]*NDIS[0]=0Q=[(0,0)]while Q:dis,now=heappop(Q)if DIS[now]!=dis:continuefor to,cost in E[now]:if DIS[to]>cost+dis:DIS[to]=cost+disheappush(Q,(DIS[to],to))ANS=0for i in range(N):ANS=max(ANS,(Y-DIS[i])//LIST[i])print(ANS)