Doubt in CSES Problem(Traffic Lights)

Problem - CSES - Traffic Lights

I am not getting this problem.I think the sample output is incorrect!

Input:
8 3
3 6 2

Output:
5 3 3

According to sample input answer should be : 5 3 2 but sample output is 5 3 3

Demonstration:

0 1 2 3 4 5 6 7 8
    ! !     !

I mean after adding 2 how the longest path without traffic light is 3 and not 2?
Somebody please help.Is there a catch which i am losing?

1 Like

Can Anyone Help?

I would imagine the street is like a line segment, and the traffic lights are like points in 1D space, meaning that the segment (3, 6) is still valid.

3 Likes

You mean that we are counting 3 as
3 4
4 5
5 6
@galencolin

Sure

While adding 6 can counting 3 like this is valid?
0 1
1 2
2 3
@galencolin

Why wouldn’t it be?

1 Like

I just got so much confused thats why i wanted to clear!

But still Thank you so much @galencolin !

I still didn’t get the logic can you please explain it more