結果
問題 |
No.1265 Balloon Survival
|
ユーザー |
![]() |
提出日時 | 2020-11-01 22:36:40 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 685 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 82,004 KB |
実行使用メモリ | 160,876 KB |
最終ジャッジ日時 | 2024-07-22 05:54:20 |
合計ジャッジ時間 | 9,225 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 TLE * 1 -- * 11 |
ソースコード
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)