結果

問題 No.1265 Balloon Survival
ユーザー yakeshiba
提出日時 2020-11-17 15:18:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,846 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 137,436 KB
最終ジャッジ日時 2024-07-23 08:18:43
合計ジャッジ時間 22,453 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import itertools

input=sys.stdin.readline


def main(args):
    n = int(input())
    
    balloons = []
    for _ in range(n):
        x, y = map(int,input().split())
        balloons.append((x, y))
    
    dist = []
    for a, b in itertools.combinations([i for i in range(n)], 2):
        x1, y1 = balloons[a]
        x2, y2 = balloons[b]
        d = (x2-x1)**2+(y2-y1)**2
        dist.append((d, a, b))
        
    dist.sort()
    
    removed = [0]*n
    ans = 0
    for d in dist:
        a = d[1]
        b = d[2]
        if a == 0:
            if removed[b] == 0:
                ans += 1
                removed[b] = 1
        else:
            if removed[a] == 0 and removed[b] == 0:
                removed[a] = 1
                removed[b] = 1
    
    print(ans)
    
if __name__ == '__main__':
    main(sys.argv[1:])
0