[백준 7869번] 두 원 (Python3)
import sys input = sys.stdin.readline from math import sqrt,pi,sin,acos def coslaw(a,b,c): cosA = (b**2+c**2-a**2)/(2*b*c) return acos(cosA) x1,y1,r1,x2,y2,r2 = map(float,input().split()) c = sqrt((x1-x2)**2+(y1-y2)**2) if not r1 or not r2 or c>=r1+r2: result = 0 elif c
[백준 1725번] 히스토그램 (Python3)
import sys input = sys.stdin.readline from heapq import heappush,heappop N = int(input()) result = 0 hq = [] for i in range(N): h = int(input()) heappush(hq,(-h,i)) while hq and -hq[0][0]>h: h1,i1 = heappop(hq) result = max(result,-h1*(i-i1)) heappush(hq,(-h,i1)) while hq: h,i = heappop(hq) result = max(result,-h*(N-i)) print(result) 우선순위 큐를 이용해서 해결하였다. 보통 세그먼트 트리, 분할정복을 이용해서 푼다고 하는데, 그 방법으로 어떻게..