88672024-02-02 17:28:39NagyLeoLegmesszebbi rossz sorrendű (35 pont)python3Wrong answer 1/3561ms42760 KiB
def find_misplaced_elements(nums):
    n = len(nums)
    max_index = 0
    min_index = n - 1

    # Find the first misplaced element from the left
    for i in range(1, n):
        if nums[i] < nums[i - 1]:
            max_index = i - 1
            break

    # Find the first misplaced element from the right
    for i in range(n - 2, -1, -1):
        if nums[i] > nums[i + 1]:
            min_index = i + 1
            break

    # Check if the sequence is already sorted
    if max_index == 0 and min_index == n - 1:
        return -1

    return max_index+1, min_index+1

# Read input
n = int(input())
nums = list(map(int, input().split()))

# Find the indices of the misplaced elements
result = find_misplaced_elements(nums)

# Print the result
if result == -1:
    print(-1)
else:
    print(result[0], result[1])
SubtaskSumTestVerdictTimeMemory
base1/35
1Accepted0/018ms11356 KiB
2Wrong answer0/048ms35548 KiB
3Accepted1/117ms12380 KiB
4Wrong answer0/117ms12592 KiB
5Wrong answer0/117ms12656 KiB
6Wrong answer0/117ms12592 KiB
7Wrong answer0/117ms12672 KiB
8Wrong answer0/117ms12976 KiB
9Wrong answer0/117ms13312 KiB
10Wrong answer0/117ms13740 KiB
11Wrong answer0/117ms14252 KiB
12Wrong answer0/228ms22748 KiB
13Wrong answer0/230ms24636 KiB
14Wrong answer0/230ms25708 KiB
15Wrong answer0/226ms21228 KiB
16Wrong answer0/232ms26692 KiB
17Wrong answer0/237ms31164 KiB
18Wrong answer0/241ms33000 KiB
19Wrong answer0/243ms35700 KiB
20Wrong answer0/246ms38720 KiB
21Wrong answer0/248ms41252 KiB
22Wrong answer0/246ms41904 KiB
23Wrong answer0/259ms42312 KiB
24Wrong answer0/261ms42760 KiB