BOJ15654 N과 M 6

randi65535·2020년 11월 27일
import sys
sys.setrecursionlimit((10**5))

N, M = map(int, input().split())

elem = list(map(int, input().split()))
elem.sort()

check = [0] * N
ans = [0] * N

## depth 깊이
def recur(depth, cnt):
	if cnt == M:
		print(' '.join(map(str, ans[:M])))
		return

	if depth >= N:
		return

	ans[cnt] = elem[depth]
	recur(depth+1, cnt+1)
	ans[cnt] = 0
	recur(depth+1, cnt)	

recur(0, 0)
profile
unsinged int 8byte-1

0개의 댓글