結果

問題 No.3093 Safe Infection
コンテスト
ユーザー timi
提出日時 2025-04-07 23:44:57
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 510 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 97 ms
コンパイル使用メモリ 64,772 KB
実行使用メモリ 92,208 KB
最終ジャッジ日時 2026-10-21 07:30:13
合計ジャッジ時間 14,506 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 71 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,M,K=map(int, input().split())
A=list(map(int, input().split()))

import heapq 
V=[-1]*N 
a=min(A)
D=[[] for i in range(N)]
for _ in range(M):
  x,y=map(int, input().split())
  x-=1;y-=1
  D[x].append(y);D[y].append(x)
  
E=[]
for i in range(N):
  if A[i]==a:
    V[i]=1 
    heapq.heappush(E,(A[i],i))

B=[a]
while E:
  s,idx=heapq.heappop(E)
  B.append(s)
  for nex in D[idx]:
    if V[nex]==-1:
      V[nex]=1;heapq.heappush(E,(A[nex],nex)) 
  if B[-1]-B[-2]>K:
    print('No')
    exit()
  
print('Yes')  
0