모험가 길드

서희찬·2021년 9월 21일
0

코테준비python 편

목록 보기
2/13

문제

코드

# 모험가 길 드  
n = int(input())
data = list(map(int,input().split()))
data.sort()

result = 0 
cnt = 0 

for i in data :
    cnt +=1 
    if cnt>=i :
        result+=1
        cnt  =0 

print(result)

해설

코드 그대로이다 !

우선 오름차순으로 정렬하고 난 후에 요소들 하나씩 for문을 도는데 if문을 성립하게 되면 result 값을 하나 올려주고 cnt 값을 초기화 시켜주면 된다 !

profile
Carnegie Mellon University Robotics Institute | Research Associate | Developing For Our Lives, 세상에 기여하는 삶을 살고자 개발하고 있습니다

0개의 댓글