Skip to content

Commit 0b3cb48

Browse files
committed
[BOJ] 센티와 마법의 뿅망치 / 실버 1 / 40분
https://www.acmicpc.net/problem/19638
1 parent b45b494 commit 0b3cb48

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import heapq
2+
3+
population, centi_height, limit = map(int, input().split())
4+
5+
arr_heights = []
6+
max_height = -1
7+
8+
for _ in range(population):
9+
heapq.heappush(arr_heights, -(int(input())))
10+
11+
if centi_height > -arr_heights[0]:
12+
print("YES")
13+
print(0)
14+
exit(0)
15+
16+
for i in range(limit):
17+
# 키가 가장 큰 거인 선택
18+
max_height = -(heapq.heappop(arr_heights))
19+
20+
# 가장 큰 거인의 키가 1인 경우 뿅망치 무효화.
21+
if max_height == 1:
22+
heapq.heappush(arr_heights, -(max_height))
23+
else:
24+
heapq.heappush(arr_heights, -(max_height//2))
25+
26+
max_height = -(heapq.heappop(arr_heights))
27+
28+
if centi_height > max_height:
29+
print("YES")
30+
print(i+1)
31+
exit(0)
32+
heapq.heappush(arr_heights, -max_height)
33+
34+
35+
print("NO")
36+
print(max_height)
37+
38+

0 commit comments

Comments
 (0)