Skip to content

Commit

Permalink
Merge pull request #256 from AlgoLeadMe/34-H0ngJu
Browse files Browse the repository at this point in the history
34-H0ngJu
  • Loading branch information
H0ngJu authored Nov 22, 2024
2 parents 3a46632 + 5cdfa11 commit 4f2c6c0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions H0ngJu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
33 changes: 33 additions & 0 deletions H0ngJu/λˆ„μ ν•©/개λ˜₯벌레.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 4f2c6c0

Please sign in to comment.