Skip to content

Commit

Permalink
2024-11-16
Browse files Browse the repository at this point in the history
  • Loading branch information
H0ngJu committed Nov 16, 2024
1 parent 0eca757 commit c13629a
Showing 1 changed file with 33 additions and 0 deletions.
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 c13629a

Please sign in to comment.