91162024-02-14 17:26:15NagyLeoKövetkező permutáció (50 pont)pypy3Time limit exceeded 4/50349ms92024 KiB
from itertools import permutations


def main():
    n = int(input())
    numbers = tuple(map(int, input().split()))

    isAfter = False

    def test(numbers):
        for i in range(n - 2):
            for j in range(i + 1, n - 1):
                for k in range(j + 1, n):
                    if numbers[j] < numbers[k] and numbers[k] < numbers[i]:
                        return False
                        # if numbers[j] < numbers[k]:
                        #    numbers[j], numbers[k] = numbers[k], numbers[j]
        return True

    for A in permutations(range(1, n + 1)):
        if test(A) and isAfter:
            print(*A)
            break
        if A == numbers:
            isAfter = True


main()
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/041ms77704 KiB
2Time limit exceeded0/0266ms25564 KiB
3Accepted1/141ms78404 KiB
4Accepted1/164ms89460 KiB
5Accepted1/1107ms92024 KiB
6Accepted1/179ms90832 KiB
7Time limit exceeded0/2263ms27520 KiB
8Time limit exceeded0/2257ms27856 KiB
9Time limit exceeded0/2277ms28176 KiB
10Time limit exceeded0/2277ms28448 KiB
11Time limit exceeded0/1279ms27812 KiB
12Time limit exceeded0/1282ms27800 KiB
13Time limit exceeded0/1273ms27868 KiB
14Time limit exceeded0/1282ms27800 KiB
15Time limit exceeded0/3282ms28212 KiB
16Time limit exceeded0/3282ms27940 KiB
17Time limit exceeded0/3277ms27556 KiB
18Time limit exceeded0/3257ms27876 KiB
19Time limit exceeded0/3277ms27540 KiB
20Time limit exceeded0/3282ms28428 KiB
21Time limit exceeded0/3270ms28448 KiB
22Time limit exceeded0/3282ms28692 KiB
23Time limit exceeded0/3257ms28628 KiB
24Time limit exceeded0/3266ms28632 KiB
25Time limit exceeded0/2349ms28644 KiB
26Time limit exceeded0/2277ms28852 KiB