3. 그리디 문제 풀이(1)
·
Python/알고리즘(Python)
곱하기 혹은 더하기s = '02984' s = list(s) max = 0 for i in range(len(s)): if s[i] != '0' and s[i] != '1': if max != 0: max *= int(s[i]) else: max += int(s[i]) else: max += int(s[i]) print(max) 모험가 길드Fear = [2,3,1,2,2] N = len(Fear) Fear = sorted(Fear) Fearless = [] group = 0 for i in Fear: Fearless.append(i) if len(Fearless) >= i: group += 1 Fearless = [] print(group) Uploaded by Notion2Tistory v1.1.0