문제
나의 풀이
1. 결국 스터디원의 풀이로..
def cal(i, sum_num, plus, minus, mul, div):
global max_num, min_num
if i == n:
max_num = max(max_num, sum_num)
min_num = min(min_num, sum_num)
return
if plus:
cal(i + 1, sum_num + num[i], plus - 1, minus, mul, div)
if minus:
cal(i + 1, sum_num - num[i], plus, minus - 1, mul, div)
if mul:
cal(i + 1, sum_num * num[i], plus, minus, mul - 1, div)
if div:
if sum_num >= 0:
cal(i + 1, sum_num // num[i], plus, minus, mul, div - 1)
if sum_num < 0:
cal(i + 1, -(-(sum_num) // num[i]), plus, minus, mul, div - 1)
n = int(input())
num = list(map(int, input().split()))
plus, minus, mul, div = map(int, input().split())
max_num, min_num = -1e9, 1e9
cal(1, num[0], plus, minus, mul, div)
print(max_num, min_num, sep = '\n')