結果

問題 No.1265 Balloon Survival
ユーザー terasaterasa
提出日時 2022-05-30 23:12:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,324 ms / 2,000 ms
コード長 1,264 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 145,708 KB
最終ジャッジ日時 2023-10-21 00:24:52
合計ジャッジ時間 15,761 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,796 KB
testcase_01 AC 41 ms
55,796 KB
testcase_02 AC 41 ms
55,792 KB
testcase_03 AC 41 ms
55,796 KB
testcase_04 AC 41 ms
55,796 KB
testcase_05 AC 42 ms
55,796 KB
testcase_06 AC 42 ms
55,796 KB
testcase_07 AC 43 ms
55,796 KB
testcase_08 AC 42 ms
55,796 KB
testcase_09 AC 44 ms
55,796 KB
testcase_10 AC 41 ms
55,796 KB
testcase_11 AC 42 ms
55,796 KB
testcase_12 AC 43 ms
55,796 KB
testcase_13 AC 42 ms
55,796 KB
testcase_14 AC 175 ms
83,012 KB
testcase_15 AC 139 ms
80,988 KB
testcase_16 AC 91 ms
77,632 KB
testcase_17 AC 616 ms
109,412 KB
testcase_18 AC 110 ms
79,024 KB
testcase_19 AC 94 ms
77,988 KB
testcase_20 AC 141 ms
82,980 KB
testcase_21 AC 301 ms
90,420 KB
testcase_22 AC 174 ms
84,952 KB
testcase_23 AC 217 ms
85,908 KB
testcase_24 AC 1,313 ms
145,628 KB
testcase_25 AC 1,318 ms
145,708 KB
testcase_26 AC 1,324 ms
145,280 KB
testcase_27 AC 956 ms
143,776 KB
testcase_28 AC 943 ms
143,652 KB
testcase_29 AC 1,232 ms
145,228 KB
testcase_30 AC 1,014 ms
143,732 KB
testcase_31 AC 1,265 ms
144,708 KB
testcase_32 AC 873 ms
144,068 KB
testcase_33 AC 975 ms
143,664 KB
testcase_34 AC 51 ms
63,588 KB
testcase_35 AC 42 ms
55,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


N = int(input())
C = [tuple(map(int, input().split())) for _ in range(N)]

h = []
for i in range(N):
    for j in range(i + 1, N):
        xi, yi = C[i]
        xj, yj = C[j]
        d = (xi - xj) ** 2 + (yi - yj) ** 2
        heapq.heappush(h, (d, (i, j)))

S = {i for i in range(N)}
ans = 0
while len(S) > 1:
    _, (a, b) = heapq.heappop(h)
    if a in S and b in S:
        if a == 0:
            S.remove(b)
            ans += 1
        else:
            S.remove(a)
            S.remove(b)
print(ans)
0