{"categories":["python"],"type":"rich","height":"190","published":"2023-01-08 17:17:26","version":"1.0","title":"\u4e21\u65b9\u5411\u3067\u898b\u3089\u308c\u308b\u512a\u5148\u5ea6\u4ed8\u304d\u30ad\u30e5\u30fc","width":"100%","provider_url":"https://hatena.blog","blog_title":"\u30b3\u30fc\u30c9\u3068\u304b","author_url":"https://blog.hatena.ne.jp/SssssI/","provider_name":"Hatena Blog","image_url":null,"html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fsssssi.hatenablog.com%2Fentry%2F2023%2F01%2F08%2F171726\" title=\"\u4e21\u65b9\u5411\u3067\u898b\u3089\u308c\u308b\u512a\u5148\u5ea6\u4ed8\u304d\u30ad\u30e5\u30fc - \u30b3\u30fc\u30c9\u3068\u304b\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","description":"\u6700\u5927\u5024\u3068\u6700\u5c0f\u5024\u3092\u4e21\u65b9O(logN)\u3067\u898b\u305f\u3044\u3001\u30ef\u30ac\u30de\u30de\u306a\u4eba\u306e\u305f\u3081\u306e\u512a\u5148\u5ea6\u4ed8\u304d\u30ad\u30e5\u30fc\u3002\u8981\u7d20\u306e\u8ffd\u52a0\u306fO(logN)\u3001\u8981\u7d20\u306e\u5b58\u5728\u78ba\u8a8d\u306fO(1)\u3002 \u305f\u3060\u3057\u3001heapq\u3092\uff12\u3064\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u4f7f\u3046\u30e1\u30e2\u30ea\u3082\uff12\u500d\u3001\u8a08\u7b97\u91cf\u3082\uff12\u500d\u3002 import heapq class HeapBiq: def __init__(self,A=[]): self.low = A self.hi = [-1*a for a in A] heapq.heapify(self.low) heapq.heapify(self.hi) self.dic = {} for a in A: if a in self.dic: self.dic[a\u2026","blog_url":"https://sssssi.hatenablog.com/","url":"https://sssssi.hatenablog.com/entry/2023/01/08/171726","author_name":"SssssI"}