91192024-02-14 18:17:13NagyLeoKövetkező permutáció (50 pont)python3Accepted 50/5026ms16780 KiB
def main():
    n = int(input())
    numbers = list(map(int, input().split()))

    for i in range(n - 1, 0, -1):
        if numbers[i] > numbers[i - 1]:
            break

    for j in range(n - 1, -1, -1):
        if numbers[j] > numbers[i - 1]:
            break

    numbers[j], numbers[i - 1] = numbers[i - 1], numbers[j]

    print(*numbers[:i], *numbers[j:], *numbers[i:j][::-1])


main()
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/017ms11348 KiB
2Accepted0/020ms12960 KiB
3Accepted1/117ms11600 KiB
4Accepted1/117ms11796 KiB
5Accepted1/117ms12212 KiB
6Accepted1/117ms11912 KiB
7Accepted2/217ms12148 KiB
8Accepted2/217ms12484 KiB
9Accepted2/217ms12484 KiB
10Accepted2/217ms12836 KiB
11Accepted1/117ms13120 KiB
12Accepted1/117ms12876 KiB
13Accepted1/117ms13060 KiB
14Accepted1/117ms13212 KiB
15Accepted3/317ms13196 KiB
16Accepted3/317ms13420 KiB
17Accepted3/317ms13980 KiB
18Accepted3/318ms14236 KiB
19Accepted3/323ms15376 KiB
20Accepted3/323ms15792 KiB
21Accepted3/324ms15940 KiB
22Accepted3/325ms16612 KiB
23Accepted3/324ms16480 KiB
24Accepted3/323ms16504 KiB
25Accepted2/226ms16616 KiB
26Accepted2/225ms16780 KiB