Baekjoon/백트래킹
[백준] 15657 N과 M (8) (실버3) / 백트래킹
hellosonic
2023. 4. 14. 10:58
문제요약
나의 코드 및 설명
def dfs(count, start_idx):
if count == m:
print(" ".join(map(str, ans)))
return
if count == n:
return
for i in range(start_idx,n):
ans.append(num_list[i])
dfs(count+1, i)
ans.pop()
n, m = map(int, input().split())
num_list = list(map(int, input().split()))
num_list.sort()
ans = []
dfs(0,0)