diff --git a/BOJ/10972.py b/BOJ/10972.py new file mode 100644 index 0000000..27e8fd7 --- /dev/null +++ b/BOJ/10972.py @@ -0,0 +1,20 @@ +# 10972 백준 실버3 다음 순열 +# 수학, 조합론 +# 해설참고 + +import sys +input = sys.stdin.readline + +n = int(input()) +array = list(map(int, input().split())) + +for i in range(n-1, 0, -1): + if array[i-1] < array[i]: + for j in range(n-1, 0, -1): + if array[i-1] < array[j]: + array[i-1], array[j] = array[j], array[i-1] + array = array[:i] + sorted(array[i:]) + print(*array) + exit() + +print(-1)