結果
問題 | No.1265 Balloon Survival |
ユーザー |
|
提出日時 | 2020-10-23 22:22:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,261 ms / 2,000 ms |
コード長 | 661 bytes |
コンパイル時間 | 320 ms |
コンパイル使用メモリ | 82,064 KB |
実行使用メモリ | 152,112 KB |
最終ジャッジ日時 | 2024-07-21 11:02:20 |
合計ジャッジ時間 | 16,330 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
import sysinput = sys.stdin.readline# def input(): return sys.stdin.readline().rstrip() # 文字列def dist(x, y):one = x[0] - y[0]two = x[1] - y[1]return one * one + two * twon = int(input())p = [tuple(map(int, input().split())) for i in range(n)]d = []for i in range(n - 1):for j in range(i + 1, n):d.append((dist(p[i], p[j]), i, j))d.sort(key=lambda x: x[0])s = set(range(n))ans = 0i = 0while len(s) > 1:_, x, y = d[i]if x == 0 or y == 0:if x + y in s:s.remove(x + y)ans += 1elif x in s and y in s:s.remove(x)s.remove(y)i += 1print(ans)