結果

問題 No.2923 Mayor's Job
ユーザー detteiuudetteiuu
提出日時 2024-10-12 14:55:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 748 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 78,376 KB
最終ジャッジ日時 2024-10-12 14:55:30
合計ジャッジ時間 2,849 ms
ジャッジサーバーID
(参考情報)
judge1 / judge
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,304 KB
testcase_01 AC 38 ms
54,188 KB
testcase_02 AC 38 ms
54,948 KB
testcase_03 AC 147 ms
77,372 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N, K = map(int, input().split())
H = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(N)]

K **= 2
def distance(x1, y1, x2, y2):
    return (x2-x1)**2 + (y2-y1)**2

H = sorted([(i, H[i]) for i in range(N)], key=lambda x:x[1], reverse=True)

ans = 0
visited = [False]*N
for idx, h in H:
    if visited[idx]:
        continue
    ans += 1
    visited[idx] = True
    que = deque()
    que.append(idx)
    while que:
        n = que.popleft()
        X1, Y1 = XY[n]
        for i in range(N):
            X2, Y2 = XY[i]
            if not visited[i] and H[idx][1] > H[i][1] and distance(X1, Y1, X2, Y2) <= K:
                visited[i] = True
                que.append(i)

print(ans)
0