Computer Science/Algorithm
[Baekjoon] Greedy - 16435 스네이크버드
ddu0422
2023. 8. 13. 10:53
문제
16435번: 스네이크버드
첫 번째 줄에 과일의 개수 N (1 ≤ N ≤ 1,000) 과 스네이크버드의 초기 길이 정수 L (1 ≤ L ≤ 10,000) 이 주어집니다. 두 번째 줄에는 정수 h1, h2, ..., hN (1 ≤ hi ≤ 10,000) 이 주어집니다.
www.acmicpc.net
풀이
n, l = map(int, input().split())
heights = list(map(int, input().split()))[:n]
def solution(l, heights):
heights.sort()
for height in heights:
if l >= height:
l += 1
return l
print(solution(l, heights))
채점 결과
