얼렁뚱땅 백준 문제풀이

[백준 문제풀이] 얼렁뚱땅 15655번 N과 M(6) 풀이

MOSTAR 2022. 7. 28. 12:49

https://www.acmicpc.net/problem/15655

 

n, m = map(int,input().split())
list_ = list(map(int,input().split()))
list_.sort()

answer= []

def dfs(depth) :
	if len(answer) == m :
		print(*answer)
	else :
		for i in range(depth,len(list_)) :
			answer.append(list_[i])
			dfs(i+1)
			answer.pop()
dfs(0)