結果
問題 |
No.3013 ハチマキ買い星人
|
ユーザー |
|
提出日時 | 2025-01-25 13:36:56 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 531 bytes |
コンパイル時間 | 229 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 364,100 KB |
最終ジャッジ日時 | 2025-01-25 22:52:45 |
合計ジャッジ時間 | 55,772 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 34 TLE * 11 |
ソースコード
from collections import deque n,m,p,y=map(int,input().split()) edge=[list(map(int,input().split())) for _ in range(m)] shop=[list(map(int,input().split())) for _ in range(p)] E=[[] for _ in range(n+1)] for a,b,c in edge: E[a].append([b,c]) E[b].append([a,c]) ds=dict() for d,e in shop: ds[d]=e D=[0]*(n+1) D[1]=y q=deque([1]) while q: x=q.popleft() for e,c in E[x]: if D[e]<max(0,D[x]-c): D[e]=max(0,D[x]-c) q.append(e) ans=0 for i in range(1,n+1): if i in ds: ans=max(ans,D[i]//ds[i]) print(ans)