結果

問題 No.1265 Balloon Survival
ユーザー 👑 KazunKazun
提出日時 2021-12-25 03:28:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 859 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 81,592 KB
実行使用メモリ 111,032 KB
最終ジャッジ日時 2023-10-20 08:29:05
合計ジャッジ時間 12,309 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,208 KB
testcase_01 AC 45 ms
55,208 KB
testcase_02 AC 44 ms
55,208 KB
testcase_03 AC 43 ms
55,208 KB
testcase_04 AC 44 ms
55,208 KB
testcase_05 AC 45 ms
55,208 KB
testcase_06 AC 44 ms
55,208 KB
testcase_07 AC 44 ms
55,208 KB
testcase_08 AC 45 ms
55,208 KB
testcase_09 AC 44 ms
55,208 KB
testcase_10 AC 44 ms
55,208 KB
testcase_11 AC 45 ms
55,208 KB
testcase_12 AC 45 ms
55,208 KB
testcase_13 AC 43 ms
55,208 KB
testcase_14 AC 119 ms
71,152 KB
testcase_15 AC 95 ms
68,300 KB
testcase_16 AC 67 ms
65,496 KB
testcase_17 AC 458 ms
100,636 KB
testcase_18 AC 77 ms
67,104 KB
testcase_19 AC 69 ms
64,332 KB
testcase_20 AC 112 ms
71,100 KB
testcase_21 AC 195 ms
79,016 KB
testcase_22 AC 138 ms
74,500 KB
testcase_23 AC 145 ms
74,944 KB
testcase_24 AC 840 ms
109,544 KB
testcase_25 AC 825 ms
110,528 KB
testcase_26 AC 843 ms
110,996 KB
testcase_27 AC 841 ms
110,516 KB
testcase_28 AC 838 ms
111,012 KB
testcase_29 AC 859 ms
111,032 KB
testcase_30 AC 847 ms
111,016 KB
testcase_31 AC 845 ms
110,524 KB
testcase_32 AC 833 ms
110,536 KB
testcase_33 AC 807 ms
110,524 KB
testcase_34 AC 43 ms
55,216 KB
testcase_35 AC 43 ms
55,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
from operator import itemgetter

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    P=[0]*N

    for i in range(N):
        P[i]=tuple(map(int,input().split()))

    dist=[0]*(N*(N-1)//2)
    I=[0]*(N*(N-1)//2)
    J=[0]*(N*(N-1)//2)

    k=0
    for i in range(N):
        for j in range(i+1,N):
            a,b=P[i][0]-P[j][0],P[i][1]-P[j][1]
            I[k]=i; J[k]=j; dist[k]=a*a+b*b
            k+=1

    A=sorted(range(N*(N-1)//2), key=lambda k:dist[k])
    Flag=[1]*N

    X=0
    for k in A:
        i=I[k]; j=J[k]
        if not(Flag[i] and Flag[j]):
            continue

        Flag[j]=0
        if i!=0:
            Flag[i]=0
        else:
            X+=1
    return X

if __name__=="__main__":
    print(main())
0