結果

問題 No.1265 Balloon Survival
ユーザー Mine
提出日時 2020-12-03 23:42:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,649 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 131,584 KB
最終ジャッジ日時 2024-09-14 09:09:07
合計ジャッジ時間 20,749 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 in range(len(d)):
    x = d[i][1]
    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