結果

問題 No.1265 Balloon Survival
ユーザー Mine
提出日時 2020-12-03 23:41:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,900 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 118,628 KB
最終ジャッジ日時 2024-09-14 09:06:32
合計ジャッジ時間 23,510 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

def distance(X, Y):
    return abs(X[0] - Y[0])**2 + abs(X[1] - Y[1])**2

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
d = []

for i in range(n):
    for g in range(i+1, n):
        d.append((distance(xy[i], xy[g]), (i, g)))
d.sort()

cnt = 0
used = [False]*n

for i, x in d:
    if used[x[0]] or used[x[1]]:
        continue
    if x[0] == 0:
        cnt += 1
        used[x[1]] = True
    else:
        used[x[0]] = True
        used[x[1]] = True

print(cnt)

0