結果
問題 | No.3013 ハチマキ買い星人 |
ユーザー |
![]() |
提出日時 | 2025-01-25 13:05:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 697 ms / 2,000 ms |
コード長 | 633 bytes |
コンパイル時間 | 320 ms |
コンパイル使用メモリ | 82,420 KB |
実行使用メモリ | 114,676 KB |
最終ジャッジ日時 | 2025-01-25 22:33:17 |
合計ジャッジ時間 | 17,432 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 45 |
ソースコード
N,M,p,X=map(int,input().split())G=[[] for i in range(N)]for i in range(M):a,b,c=map(int,input().split())G[a-1].append((b-1,c))G[b-1].append((a-1,c))A=[10**18]*Nfor i in range(p):d,e=map(int,input().split())A[d-1]=eresult=0from heapq import heappush,heappopS=[]dp=[10**18]*Ndp[0]=0heappush(S,0)kaku=[False]*Nwhile S:w=heappop(S)time=w//(10**6)pos=w%(10**6)if kaku[pos]==True:continuekaku[pos]=Truefor B in G[pos]:z,c=B[:]if dp[z]>dp[pos]+c:dp[z]=dp[pos]+cheappush(S,dp[z]*10**6+z)for i in range(N):rest=X-dp[i]result=max(result,rest//A[i])print(result)