結果
| 問題 | No.3013 ハチマキ買い星人 |
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2025-01-25 12:48:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 969 ms / 2,000 ms |
| コード長 | 523 bytes |
| コンパイル時間 | 279 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 121,472 KB |
| 最終ジャッジ日時 | 2025-01-25 22:21:55 |
| 合計ジャッジ時間 | 21,740 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / 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-=1
b-=1
e[a]+=[(b,c)]
e[b]+=[(a,c)]
X=10**20
h=[X]*n
for i in range(p):
u,v=map(int,input().split())
u-=1
h[u]=v
from heapq import heappush,heappop
v=[X]*n
s=0
v[s]=0
q=[(v[s],s)]
while len(q)>0:
sc,sp=heappop(q)
if sc>v[sp]:
continue
for tp,tc in e[sp]:
if v[tp]>sc+tc:
v[tp]=sc+tc
heappush(q,(v[tp],tp))
ans=0
for i in range(n):
ans=max(ans,(Y-v[i])//h[i])
print(ans)
sasa8uyauya