DevYoon
[SWEA] 1952. μμμ₯ λ³Έλ¬Έ
link π https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PpFQaAQMDFAUq
1οΈβ£ DFS μ¬μ© → 맀κ°λ³μλ‘ λ¬(month)μ μκΈν©κ³ μ¬μ©
2οΈβ£ 1μΌ μκΈμ μ¬μ©νμ λ, 1λ¬ μκΈμ μ¬μ©νμ λ, 3λ¬ μκΈμ μ¬μ©νμ λ, 1λ μκΈμ μ¬μ©νμ λ
3οΈβ£ Min = 1λ μκΈμ
def dfs(month, sums):
global cost, Min
if month > 11:
if Min > sums:
Min = sums
return
dfs(month+1, sums+(cost[0]*m[month]))
dfs(month+1, sums+cost[1])
dfs(month+3, sums+cost[2])
dfs(month+12, sums+cost[3])
t = int(input())
for tc in range(1, t+1):
cost = list(map(int, input().split()))
m = list(map(int, input().split()))
Min = cost[3] # 1λ
μκΈ
dfs(0, 0) # λ¬, μκΈν©κ³
print(f'#{tc} {Min}')