結果
問題 |
No.1265 Balloon Survival
|
ユーザー |
|
提出日時 | 2020-11-17 15:23:22 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 996 ms / 2,000 ms |
コード長 | 865 bytes |
コンパイル時間 | 494 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 138,964 KB |
最終ジャッジ日時 | 2024-07-23 08:20:00 |
合計ジャッジ時間 | 12,413 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
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 i in range(n): for j in range(i+1,n): x1, y1 = balloons[i] x2, y2 = balloons[j] d = (x2-x1)**2+(y2-y1)**2 dist.append((d, i, j)) dist.sort(key=lambda x: x[0]) 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:])