結果
問題 | No.1265 Balloon Survival |
ユーザー | terasa |
提出日時 | 2022-05-30 23:22:27 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,438 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 81,848 KB |
実行使用メモリ | 171,796 KB |
最終ジャッジ日時 | 2023-10-21 00:25:21 |
合計ジャッジ時間 | 9,433 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
55,756 KB |
testcase_01 | AC | 46 ms
55,756 KB |
testcase_02 | AC | 45 ms
55,752 KB |
testcase_03 | AC | 45 ms
55,756 KB |
testcase_04 | AC | 46 ms
55,756 KB |
testcase_05 | AC | 42 ms
55,756 KB |
testcase_06 | AC | 42 ms
55,756 KB |
testcase_07 | AC | 47 ms
55,756 KB |
testcase_08 | AC | 45 ms
55,756 KB |
testcase_09 | AC | 46 ms
55,756 KB |
testcase_10 | AC | 44 ms
55,756 KB |
testcase_11 | AC | 44 ms
55,756 KB |
testcase_12 | AC | 44 ms
55,756 KB |
testcase_13 | AC | 42 ms
55,756 KB |
testcase_14 | AC | 294 ms
85,932 KB |
testcase_15 | AC | 219 ms
82,760 KB |
testcase_16 | AC | 112 ms
78,428 KB |
testcase_17 | AC | 1,143 ms
122,460 KB |
testcase_18 | AC | 142 ms
80,044 KB |
testcase_19 | AC | 123 ms
78,864 KB |
testcase_20 | AC | 210 ms
85,660 KB |
testcase_21 | AC | 568 ms
98,084 KB |
testcase_22 | AC | 271 ms
89,036 KB |
testcase_23 | AC | 385 ms
90,484 KB |
testcase_24 | TLE | - |
testcase_25 | TLE | - |
testcase_26 | TLE | - |
testcase_27 | AC | 1,950 ms
166,548 KB |
testcase_28 | AC | 1,866 ms
166,492 KB |
testcase_29 | TLE | - |
testcase_30 | AC | 1,875 ms
166,520 KB |
testcase_31 | TLE | - |
testcase_32 | AC | 1,605 ms
166,524 KB |
testcase_33 | AC | 1,855 ms
166,492 KB |
testcase_34 | AC | 50 ms
63,800 KB |
testcase_35 | AC | 39 ms
55,756 KB |
ソースコード
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)] class Dist: def __init__(self, d, x, y): self.d = d self.pair = (x, y) def __lt__(self, other): return self.d < other.d 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, Dist(d, i, j)) S = {i for i in range(N)} ans = 0 while len(S) > 1: dist = heapq.heappop(h) a, b = dist.pair 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)