https://www.acmicpc.net/problem/17127
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | def recur(remainder, length): global answer if length == 0: if remainder == 0: v = 0 local_maximum = 0 for i in tmp: local_maximum += mul(a[v:v+i]) v += i answer = max(answer, local_maximum) return for i in range(1,remainder+1): tmp.append(i) recur(remainder-i, length-1) tmp.pop() def mul(lst): a = 1 for i in range(len(lst)): a *= lst[i] return a n = int(input()) a = list(map(int, input().split())) tmp = [] answer = 0 recur(n, 4) print(answer) | cs |
728x90
반응형
'Problem Solving > BOJ' 카테고리의 다른 글
[Python]17143. 낚시왕 (0) | 2019.04.18 |
---|---|
[Python]2529. 부등호 (0) | 2019.04.16 |
[Python]15559. 내 선물을 받아줘 (0) | 2019.04.14 |
[Python]13335. 트럭 (0) | 2019.04.13 |
[Python]16985. Maaaaaaaaaaze (0) | 2019.04.12 |
댓글