結果

問題 No.1265 Balloon Survival
ユーザー uni_pythonuni_python
提出日時 2020-11-01 22:50:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,651 ms / 2,000 ms
コード長 888 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 134,200 KB
最終ジャッジ日時 2023-09-29 11:29:58
合計ジャッジ時間 21,408 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,492 KB
testcase_01 AC 68 ms
71,332 KB
testcase_02 AC 70 ms
71,456 KB
testcase_03 AC 71 ms
71,424 KB
testcase_04 AC 69 ms
71,296 KB
testcase_05 AC 71 ms
71,312 KB
testcase_06 AC 71 ms
71,140 KB
testcase_07 AC 71 ms
71,108 KB
testcase_08 AC 70 ms
71,312 KB
testcase_09 AC 72 ms
71,620 KB
testcase_10 AC 70 ms
71,296 KB
testcase_11 AC 70 ms
71,456 KB
testcase_12 AC 70 ms
71,148 KB
testcase_13 AC 71 ms
71,616 KB
testcase_14 AC 193 ms
79,836 KB
testcase_15 AC 157 ms
78,736 KB
testcase_16 AC 99 ms
76,192 KB
testcase_17 AC 752 ms
102,032 KB
testcase_18 AC 119 ms
77,048 KB
testcase_19 AC 106 ms
76,196 KB
testcase_20 AC 189 ms
79,848 KB
testcase_21 AC 397 ms
96,892 KB
testcase_22 AC 236 ms
81,644 KB
testcase_23 AC 253 ms
82,420 KB
testcase_24 AC 1,574 ms
134,024 KB
testcase_25 AC 1,620 ms
133,568 KB
testcase_26 AC 1,601 ms
133,888 KB
testcase_27 AC 1,603 ms
133,868 KB
testcase_28 AC 1,592 ms
133,816 KB
testcase_29 AC 1,651 ms
134,200 KB
testcase_30 AC 1,599 ms
133,616 KB
testcase_31 AC 1,584 ms
133,872 KB
testcase_32 AC 1,606 ms
133,908 KB
testcase_33 AC 1,589 ms
133,752 KB
testcase_34 AC 70 ms
71,432 KB
testcase_35 AC 70 ms
71,624 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()))


def main():
    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

    L=[]

    for i in range(N):
        for j in range(i+1,N):
            d=(X[i]-X[j])**2 + (Y[i]-Y[j])**2
            L.append((d,i,j))

    ans=0
    L.sort()
    S=0

    for aaa in L:
        _,i,j=aaa
        if i==0:
            if used[j]==0:
                ans+=1
                used[j]=1
                S+=1
        if used[i]==0 and used[j]==0:
            used[i]=1
            used[j]=1
            S+=2
        if S==N-1:
            break
            
    print(ans)
main()
0