117552024-11-09 02:17:09balintTűzijátékpython3Accepted 50/5068ms14968 KiB
def main():
    N, S, T = map(int, input().split())
    nums = list(map(int, input().split()))
    returning = 1
    poses = [S]
    # left
    i = S - 2
    left_min = nums[S - 1]
    while i >= 0:
        if nums[i] <= left_min - T:
            left_min = nums[i]
            returning += 1
            poses.append(i + 1)
        i -= 1

    poses.sort()
    # right
    i = S
    right_max = nums[S - 1]
    while i < N:
        if nums[i] >= right_max + T:
            right_max = nums[i]
            returning += 1
            poses.append(i + 1)
        i += 1
    print(returning)
    print(*poses)


main()
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/016ms3128 KiB
2Accepted0/068ms14688 KiB
3Accepted2/216ms3128 KiB
4Accepted2/217ms3128 KiB
5Accepted2/216ms3128 KiB
6Accepted2/217ms3128 KiB
7Accepted2/216ms3128 KiB
8Accepted2/216ms3144 KiB
9Accepted2/219ms3896 KiB
10Accepted2/220ms4144 KiB
11Accepted2/220ms4152 KiB
12Accepted2/227ms5136 KiB
13Accepted2/225ms5252 KiB
14Accepted2/225ms5272 KiB
15Accepted3/326ms5300 KiB
16Accepted3/332ms6548 KiB
17Accepted3/337ms7784 KiB
18Accepted3/341ms9324 KiB
19Accepted3/368ms14968 KiB
20Accepted3/368ms14864 KiB
21Accepted4/464ms14816 KiB
22Accepted4/464ms14884 KiB