Skip to content

Commit

Permalink
[BOJ] 10972(#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
heerucan committed May 21, 2022
1 parent 152dbac commit 8c108dd
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions BOJ/10972.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 8c108dd

Please sign in to comment.