본문 바로가기
python-algorithm

백준 16435 스네이크버드

by 무적김두칠 2021. 8. 26.

1
2
3
4
5
6
7
8
import sys
n,l=map(int, sys.stdin.readline().split())
h=list(map(int, sys.stdin.readline().split()))
h.sort()
for i in h:
  if l>=i: l+=1
  else:break
print(l)
cs

그리디 알고리즘이구요
스네이크버드의 길이를 최대화 하고싶다-> 작은것부터 먹어야함

 

반응형

'python-algorithm' 카테고리의 다른 글

백준 22993 서든어택 3  (0) 2021.08.26
백준 16471 작은 수 내기  (0) 2021.08.26
백준 14469 소가 길을 건너간 이유 3  (0) 2021.08.26
백준 11256 사탕  (0) 2021.08.26
백준 9237 이장님 초대  (0) 2021.08.26

댓글