- [[백준] 1038번 감소하는 수]와 동일한 형태의 문제였다. 정말 쉽게 풀었다.
from itertools import combinations
import sys
input = sys.stdin.readline
N = int(input().strip())
arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
res = []
for i in range(1, 11):
for j in combinations(arr, i):
j = list(j)
j.sort(reverse=True)
j = int(''.join(map(str, j)))
res.append(j)
res.sort()
try:
print(res[N-1])
except IndexError:
print(-1)