노트

[백준] 18429번 근손실 python 본문

알고리즘

[백준] 18429번 근손실 python

_Myway 2023. 6. 23. 21:52
n, k = map(int, input().split())
kit = list(map(int, input().split()))
used = [0] * n
ans = 0

def dfs(a, weight):
    global ans

    if weight < 500:
        return
    if a >= n:
        ans += 1
        return

    for i in range(n):
        if used[i] == 0:
            used[i] = 1
            dfs(a + 1, weight + kit[i] - k)
            used[i] = 0

dfs(0, 500)
print(ans)
Comments