https://www.codetree.ai/missions/8/problems/keep-picking-the-big-number/description
import sys
from heapq import heappush, heappop, heapify
input = sys.stdin.readline
n, m = map(int, input().split())
num = list(map(int, input().rstrip().split()))
num = [-x for x in num]
heapify(num)
for _ in range(m):
max_val = -heappop(num)
heappush(num, -(max_val-1))
print(-num[0])
728x90
반응형
'🔻PS > Codetree' 카테고리의 다른 글
[Codetree] 숫자가 더 큰 인접한 곳으로 이동 Python (0) | 2024.09.02 |
---|---|
[Codetree] 빙하 Python (0) | 2024.09.02 |
[Codetree] 정수 명령 처리 6 Python (0) | 2024.08.09 |
[Codetree] 가장 많은 데이터 Python (0) | 2024.08.08 |
[Codetree] 가장 먼저 나오는 숫자 Python (0) | 2024.08.08 |