結果
| 問題 |
No.2923 Mayor's Job
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 15:21:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 194 ms / 2,000 ms |
| コード長 | 1,275 bytes |
| コンパイル時間 | 265 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 105,344 KB |
| 最終ジャッジ日時 | 2024-10-12 15:21:04 |
| 合計ジャッジ時間 | 3,070 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
import sys
import math
from itertools import product, permutations, combinations, accumulate
from heapq import heapify, heappush, heappop
from collections import deque, defaultdict, Counter
from bisect import bisect, bisect_left, bisect_right
from copy import copy, deepcopy
#from sortedcontainers import SortedSet, SortedList, SortedDict
sys.setrecursionlimit(10**7)
INF = float('inf')
LINF = 1 << 60
MOD = 10**9+7
def mii():
return map(int, sys.stdin.readline().split())
N, K = mii()
H = list(mii())
XY = []
for i in range(N):
XY.append(list(mii()))
graph = [[] for _ in range(N)]
def near(p1, p2):
dist = (p1[0] - p2[0])**2 + (p1[1] - p2[1]) ** 2
return dist <= K**2
indices = [0] * N
for i in range(N):
for j in range(i+1, N):
if H[i] < H[j] and near(XY[i], XY[j]):
graph[i].append(j)
indices[j] += 1
elif H[i] > H[j] and near(XY[i], XY[j]):
graph[j].append(i)
indices[i] += 1
que = deque()
for i in range(N):
if indices[i] == 0:
que.append(i)
cnt = N
while len(que):
u = que.pop()
if len(graph[u]) >= 1:
cnt -= 1
for v in graph[u]:
indices[v] -= 1
if indices[v] == 0:
que.append(v)
print(cnt)