Greedy Algorithm python
2022. 12. 5. 13:49
공포도 X인 모험가는 반드시 X명 이상으로 구성
입력
- 첫째줄: N
- 둘째줄: N명의 공포도
출력
- 길드 그룹의 최대값
Greedy Algorithm
def main():
n = int(input())
group = list(map(int, input().split()))
group.sort()
result = 0
count = 0
for x in group:
count += 1
if count >= x:
count = 0
result += 1
print(result)
if __name__ == "__main__":
main()
'Programming > Algorithm' 카테고리의 다른 글
[백준] #10951 문자 개수 모를 때 입력 받기 c++ (0) | 2022.12.21 |
---|---|
[백준] #10952 while(true) c++ (0) | 2022.12.21 |
[백준] #1541 Greedy Algorithm python (0) | 2022.12.05 |
[백준] #1931 Greedy Algorithm python (0) | 2022.12.05 |
[백준] #5585 Greedy Algorithm python (0) | 2022.12.05 |