結果
問題 | No.2431 Viral Hotel |
ユーザー |
![]() |
提出日時 | 2023-08-19 00:12:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 385 ms / 2,000 ms |
コード長 | 849 bytes |
コンパイル時間 | 267 ms |
コンパイル使用メモリ | 82,452 KB |
実行使用メモリ | 95,580 KB |
最終ジャッジ日時 | 2024-11-28 12:08:27 |
合計ジャッジ時間 | 11,931 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 42 |
ソースコード
from heapq import heappush, heappopimport sysinput = sys.stdin.readlineN, K, M, P = map(int, input().split())G = [[] for _ in range(N)]for _ in range(M):u, v = map(int, input().split())u -= 1v -= 1G[u].append(v)G[v].append(u)s = [int(input()) for _ in range(N)]x = [int(input())-1 for _ in range(K)]heap = []INF = 10**10infected = [INF] * Nremoved = [-1] * Nfor y in x:infected[y] = 0heappush(heap, (s[y], y))ans = 0while heap:t, v = heappop(heap)if removed[v] != -1 and removed[v] < t:continuecontinuefor u in G[v]:if t >= infected[u] + P or removed[u] != -1:continueif infected[u] == INF:infected[u] = theappush(heap, (t + s[u], u))else:removed[u] = tans += 1print(ans)