94342024-02-21 17:16:02NagyLeoTűzijátékpython3Accepted 50/5067ms35776 KiB
def main2():
    N, S, T = map(int, input().split())
    loc = list(map(int, input().split()))

    target = S-1

    ans = [1]
    last = loc[0]
    for i in range(1, N):
        if last+T <= loc[i]:
            if i+1 == target and loc[i]+T > loc[i+1]:
                continue
            ans.append(i+1)
            last = loc[i]

    print(len(ans))
    print(*ans)


def main():
    N, S, T = map(int, input().split())
    loc = list(map(int, input().split()))

    target = S - 1

    ans = [target + 1]
    last = loc[target]
    for i in range(target + 1, N):

        if last + T <= loc[i]:
            # if i+1 == target and loc[i]+T > loc[i+1]:
            #    continue
            ans.append(i + 1)
            last = loc[i]

    # ans2=[]
    last = loc[target]
    for i in range(target - 1, -1, -1):
        if last - T >= loc[i]:
            ans.append(i + 1)
            last = loc[i]

    print(len(ans))
    print(*sorted(ans))

main()
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/017ms11204 KiB
2Accepted0/064ms33136 KiB
3Accepted2/219ms11428 KiB
4Accepted2/218ms11864 KiB
5Accepted2/217ms12288 KiB
6Accepted2/217ms12176 KiB
7Accepted2/218ms12660 KiB
8Accepted2/217ms12652 KiB
9Accepted2/220ms14164 KiB
10Accepted2/221ms15060 KiB
11Accepted2/221ms14984 KiB
12Accepted2/226ms17216 KiB
13Accepted2/226ms17396 KiB
14Accepted2/226ms17480 KiB
15Accepted3/326ms17592 KiB
16Accepted3/332ms19708 KiB
17Accepted3/335ms21980 KiB
18Accepted3/339ms25272 KiB
19Accepted3/367ms35488 KiB
20Accepted3/367ms35332 KiB
21Accepted4/464ms35304 KiB
22Accepted4/461ms35776 KiB