結果

問題 No.1265 Balloon Survival
コンテスト
ユーザー kohei2019
提出日時 2022-07-19 21:59:50
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 1,232 ms / 2,000 ms
コード長 473 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 272 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 144,412 KB
最終ジャッジ日時 2026-03-23 05:42:01
合計ジャッジ時間 16,207 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
lsxy = [tuple(map(int,input().split())) for i in range(N)]
ls = []
for i in range(N-1):
    for j in range(i+1,N):
        dist = (lsxy[i][0]-lsxy[j][0])**2 + (lsxy[i][1]-lsxy[j][1])**2
        ls.append((dist,i,j))
ls.sort()
ans = 0
used = [False]*N
for d,a,b in ls:
    if a == 0 and used[b] == False:
        used[b] = True
        ans += 1
    elif used[a] or used[b]:
        continue
    else:
        used[a] = True
        used[b] = True
print(ans)
0