結果

問題 No.3013 ハチマキ買い星人
ユーザー hato336
提出日時 2025-01-25 12:49:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 826 ms / 2,000 ms
コード長 1,024 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 128,784 KB
最終ジャッジ日時 2025-01-25 22:22:30
合計ジャッジ時間 20,904 ms
ジャッジサーバーID
(参考情報)
judge6 / judge8
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
input = sys.stdin.readline
#n = int(input())
#alist = list(map(int,input().split()))
#alist = []
#s = input()
n,m,p,y= map(int,input().split())
#for i in range(n):
#    alist.append(list(map(int,input().split())))
edge = [[] for i in range(n)]
for i in range(m):
    u,v,c = map(int,input().split())
    u-=1
    v-=1
    edge[u].append((v,c))
    edge[v].append((u,c))
z = [10**18 for i in range(n)]
for i in range(p):
    d,e = map(int,input().split())
    z[d-1] = e
start = 0
d = []
dist = [10**18 for i in range(n)]
heapq.heappush(d,(0,0))
dist[start] = 0
while d:
    _,now = heapq.heappop(d)
    if _ > dist[now]:
        continue
    for to,cost in edge[now]:
        if dist[to] > dist[now] + cost:
            dist[to] = dist[now] + cost
            heapq.heappush(d,(dist[to],to))
ans = 0
for i in range(n):
    ans = max(ans,(y-dist[i])//z[i])
print(ans)
0