88722024-02-02 18:15:49NagyLeoLegmesszebbi rossz sorrendű (35 pont)python3Wrong answer 0/3550ms37688 KiB
def find_misplaced_elements(nums, n):
    max_length = -1
    first_num = 0
    second_num = 0
    minimums = [0] * n
    # minimums[-i] megmondja a leghatso i minimumat
    minimums[-1] = nums[-1]
    for i in range(n - 2, -1, -1):
        minimums[i] = min(minimums[i + 1], nums[i])
    for i in range(n - 1):
        if minimums[i + 1] > nums[i]:
            continue
        if minimums[-1] < nums[i]:
            if n - 1 - i > max_length:
                max_length = n - 1 - i
                first_num = i
                second_num = n - 1
                continue
        lo = i + 1
        hi = n - 1
        while hi - lo > 1:
            mid = (lo + hi) // 2
            if minimums[mid] < nums[i]:
                lo = mid
            else:
                hi = mid
        if lo - i > max_length:
            max_length = lo - i
            first_num = i
            second_num = lo

    if max_length > -1:
        print(first_num + 1, second_num + 1)
    else:
        print(-1)


n = int(input())
nums = list(map(int, input().split()))
SubtaskSumTestVerdictTimeMemory
base0/35
1Wrong answer0/018ms11368 KiB
2Wrong answer0/050ms34784 KiB
3Wrong answer0/117ms11948 KiB
4Wrong answer0/117ms12160 KiB
5Wrong answer0/117ms12156 KiB
6Wrong answer0/117ms12212 KiB
7Wrong answer0/118ms12596 KiB
8Wrong answer0/118ms13092 KiB
9Wrong answer0/117ms13016 KiB
10Wrong answer0/118ms13448 KiB
11Wrong answer0/118ms14092 KiB
12Wrong answer0/229ms22108 KiB
13Wrong answer0/232ms23480 KiB
14Wrong answer0/232ms24424 KiB
15Wrong answer0/226ms20056 KiB
16Wrong answer0/232ms25388 KiB
17Wrong answer0/239ms29188 KiB
18Wrong answer0/241ms33364 KiB
19Wrong answer0/246ms33184 KiB
20Wrong answer0/245ms35296 KiB
21Wrong answer0/246ms37248 KiB
22Wrong answer0/248ms37424 KiB
23Wrong answer0/250ms37688 KiB
24Wrong answer0/250ms37252 KiB