백준 9237번: 이장님 초대

danbibibi·2021년 11월 17일

문제

문제 바로가기> 백준 9237번: 이장님 초대

풀이

자라는데 가장 오래 걸리는 나무부터 심으면 이장님을 최대한 빨리 초대할 수 있다.

def solution():
    import sys
    input = sys.stdin.readline
    n = int(input())
    days = list(map(int, input().split()))
    days.sort(reverse=True)
    now, end = 0, 0
    for i in days:
        if end<now+1+i:
            end = now+1+i
        now+=1
    print(end+1)
solution()
profile
블로그 이전) https://danbibibi.tistory.com

0개의 댓글