結果

問題 No.1265 Balloon Survival
ユーザー uni_pythonuni_python
提出日時 2020-11-01 22:36:40
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 685 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 158,912 KB
最終ジャッジ日時 2023-09-29 11:26:13
合計ジャッジ時間 32,203 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,268 KB
testcase_01 AC 71 ms
71,280 KB
testcase_02 AC 70 ms
71,400 KB
testcase_03 AC 75 ms
71,440 KB
testcase_04 AC 75 ms
71,520 KB
testcase_05 AC 75 ms
71,208 KB
testcase_06 AC 75 ms
71,380 KB
testcase_07 AC 74 ms
71,332 KB
testcase_08 AC 75 ms
71,352 KB
testcase_09 AC 73 ms
71,208 KB
testcase_10 AC 74 ms
71,596 KB
testcase_11 AC 74 ms
71,432 KB
testcase_12 AC 77 ms
71,336 KB
testcase_13 AC 75 ms
71,328 KB
testcase_14 AC 300 ms
86,604 KB
testcase_15 AC 230 ms
84,712 KB
testcase_16 AC 146 ms
79,440 KB
testcase_17 AC 1,199 ms
113,416 KB
testcase_18 AC 175 ms
81,340 KB
testcase_19 AC 152 ms
79,628 KB
testcase_20 AC 290 ms
86,724 KB
testcase_21 AC 555 ms
95,072 KB
testcase_22 AC 348 ms
88,556 KB
testcase_23 AC 391 ms
90,496 KB
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 AC 82 ms
75,704 KB
testcase_35 AC 72 ms
71,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))



N=I()

if N==1:
    print(0)
    exit()
if N==2:
    print(1)
    exit()

X=[0]*N
Y=[0]*N
for i in range(N):
    X[i],Y[i]=MI()

# 取り除いた or 消えた
used=[0]*N

import heapq
hq=[]
for i in range(N):
    for j in range(i+1,N):
        d=(X[i]-X[j])**2 + (Y[i]-Y[j])**2
        heapq.heappush(hq,(d,i,j))

ans=0
while hq:
    _,i,j=heapq.heappop(hq)
    if i==0:
        if used[j]==0:
            ans+=1
            used[j]=1
    if used[i]==0 and used[j]==0:
        used[i]=1
        used[j]=1
        
print(ans)
0