diff --git a/froglike6/README.md b/froglike6/README.md index 0470a70..5ea1f20 100644 --- a/froglike6/README.md +++ b/froglike6/README.md @@ -22,4 +22,5 @@ | 18차시 | 2025.07.03 | 자릿수를 이용한 다이나믹 프로그래밍 | [합 찾기](https://www.acmicpc.net/problem/7786)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/69| | 19차시 | 2025.07.04 | 애드 혹 | [서로소 그래프 게임](https://www.acmicpc.net/problem/34035)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/72| | 20차시 | 2025.07.09 | 조합론 | [암호 만들기](https://www.acmicpc.net/problem/1759)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/77| + | 21차시 | 2025.07.14 | 기하학 | [Cows](https://www.acmicpc.net/problem/6850)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/82| --- diff --git a/froglike6/geometry/6850.py b/froglike6/geometry/6850.py new file mode 100644 index 0000000..76d40b8 --- /dev/null +++ b/froglike6/geometry/6850.py @@ -0,0 +1,41 @@ +import sys +input = sys.stdin.readline + +def cross(o, a, b): + return (a[0]-o[0])*(b[1]-o[1])-(a[1]-o[1])*(b[0]-o[0]) + +def convex_hull(points): + points = sorted(set(points)) + + if len(points) <= 1: + return points + + lower = [] + for p in points: + while len(lower) >= 2 and cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + + upper = [] + for p in reversed(points): + while len(upper) >= 2 and cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + + return lower[:-1] + upper[:-1] + +def shoelace_area(polygon): + n = len(polygon) + area = 0 + for i in range(n): + x1, y1 = polygon[i] + x2, y2 = polygon[(i + 1) % n] + area += (x1 * y2) - (x2 * y1) + return abs(area) / 2 + +input_points = [] +for _ in range(int(input())): + a, b = map(int,input().split()) + input_points.append((a,b)) + +print(int(shoelace_area(convex_hull(input_points))//50)) \ No newline at end of file