Skip to content

Commit b83b307

Browse files
committed
[BOJ] 국회의원 선거 / 실버 4 / 40분
https://www.acmicpc.net/problem/1417
1 parent 086597f commit b83b307

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import heapq
2+
3+
n = int(input())
4+
5+
hq = []
6+
for i in range(n):
7+
votes = int(input())
8+
if i == 0:
9+
dasom_votes = votes
10+
continue
11+
12+
heapq.heappush(hq, -votes)
13+
14+
bribe_count = 0
15+
while hq:
16+
votes = -heapq.heappop(hq)
17+
if votes < dasom_votes:
18+
break
19+
20+
dasom_votes += 1
21+
bribe_count += 1
22+
heapq.heappush(hq, -(votes - 1))
23+
24+
print(bribe_count)

0 commit comments

Comments
 (0)