結果

問題 No.2431 Viral Hotel
ユーザー sotanishysotanishy
提出日時 2023-08-19 00:12:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 849 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 97,856 KB
最終ジャッジ日時 2023-08-19 00:12:41
合計ジャッジ時間 13,302 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 299 ms
93,244 KB
testcase_01 AC 274 ms
91,348 KB
testcase_02 AC 323 ms
92,052 KB
testcase_03 AC 361 ms
95,528 KB
testcase_04 AC 304 ms
94,596 KB
testcase_05 AC 366 ms
97,308 KB
testcase_06 AC 96 ms
79,828 KB
testcase_07 AC 92 ms
79,612 KB
testcase_08 AC 91 ms
79,604 KB
testcase_09 AC 68 ms
71,312 KB
testcase_10 AC 60 ms
71,536 KB
testcase_11 AC 60 ms
71,260 KB
testcase_12 AC 383 ms
97,856 KB
testcase_13 AC 335 ms
94,220 KB
testcase_14 AC 278 ms
87,396 KB
testcase_15 AC 158 ms
81,284 KB
testcase_16 AC 254 ms
89,732 KB
testcase_17 AC 243 ms
85,724 KB
testcase_18 AC 334 ms
93,096 KB
testcase_19 AC 331 ms
90,112 KB
testcase_20 AC 204 ms
85,232 KB
testcase_21 AC 218 ms
83,344 KB
testcase_22 AC 277 ms
88,832 KB
testcase_23 AC 279 ms
88,776 KB
testcase_24 AC 231 ms
87,280 KB
testcase_25 AC 326 ms
93,100 KB
testcase_26 AC 282 ms
90,252 KB
testcase_27 AC 253 ms
88,216 KB
testcase_28 AC 260 ms
87,680 KB
testcase_29 AC 230 ms
86,724 KB
testcase_30 AC 253 ms
87,420 KB
testcase_31 AC 289 ms
91,180 KB
testcase_32 AC 222 ms
81,992 KB
testcase_33 AC 239 ms
86,080 KB
testcase_34 AC 134 ms
79,612 KB
testcase_35 AC 187 ms
81,996 KB
testcase_36 AC 346 ms
92,632 KB
testcase_37 AC 251 ms
88,716 KB
testcase_38 AC 212 ms
84,896 KB
testcase_39 AC 60 ms
71,396 KB
testcase_40 AC 60 ms
71,352 KB
testcase_41 AC 61 ms
71,240 KB
testcase_42 AC 59 ms
71,116 KB
testcase_43 AC 335 ms
96,420 KB
testcase_44 AC 317 ms
90,760 KB
testcase_45 AC 241 ms
87,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
import sys
input = sys.stdin.readline


N, K, M, P = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    G[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**10
infected = [INF] * N
removed = [-1] * N
for y in x:
    infected[y] = 0
    heappush(heap, (s[y], y))
ans = 0
while heap:
    t, v = heappop(heap)
    if removed[v] != -1 and removed[v] < t:
        continue
        continue
    for u in G[v]:
        if t >= infected[u] + P or removed[u] != -1:
            continue
        if infected[u] == INF:
            infected[u] = t
            heappush(heap, (t + s[u], u))
        else:
            removed[u] = t
            ans += 1
print(ans)
0