diff --git a/H0ngJu/README.md b/H0ngJu/README.md index 756797b..c36db45 100644 --- a/H0ngJu/README.md +++ b/H0ngJu/README.md @@ -35,3 +35,4 @@ | 31차시 | 2024.10.05 | 정렬 | [선 긋기](https://www.acmicpc.net/problem/2170) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/249 | | 32차시 | 2024.10.14 | 이분 탐색 | [기타 레슨](https://www.acmicpc.net/problem/2343) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/252 | | 33차시 | 2024.11.08 | 백트래킹 | [병원 거리 최소화](https://www.codetree.ai/training-field/frequent-problems/problems/min-of-hospital-distance/submissions?page=11&pageSize=5) | https://github.com/AlgoLeadMe/AlgoLeadMe-1/pull/253 | +| 34차시 | 2024.11.19 | 누적합 | [개똥벌레](https://www.acmicpc.net/problem/3020) | diff --git "a/H0ngJu/\353\210\204\354\240\201\355\225\251/\352\260\234\353\230\245\353\262\214\353\240\210.py" "b/H0ngJu/\353\210\204\354\240\201\355\225\251/\352\260\234\353\230\245\353\262\214\353\240\210.py" new file mode 100644 index 0000000..ba4b587 --- /dev/null +++ "b/H0ngJu/\353\210\204\354\240\201\355\225\251/\352\260\234\353\230\245\353\262\214\353\240\210.py" @@ -0,0 +1,33 @@ +import sys + +def input() : return sys.stdin.readline().rstrip() + +N, H = map(int, input().split()) +# N <= 200000, H<= 500000 +# 석순, 종유석, 석순, 종유석 ... +up = [0 for _ in range(H+1)] +down = [0 for _ in range(H+1)] +min_broke = 1e9 +broke_cnt = 0 + +for i in range(N): + info_h = int(input()) + if i % 2 == 0: + down[info_h] += 1 + else: + up[info_h] += 1 + +for i in range(H-1, 0, -1): + down[i] += down[i+1] + up[i] += up[i+1] + +for i in range(1, H+1): + broke = up[i] + down[H-i+1] + if broke < min_broke: + min_broke = broke + broke_cnt = 1 + elif broke == min_broke: + broke_cnt += 1 + +print(min_broke, broke_cnt) +