akashAgrawal's blog

By akashAgrawal, history, 4 years ago, In English

Problem — https://cses.fi/problemset/task/1163 13

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 the sample, the input answer should be: 5 3 2 but the 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 that I am losing?

  • Vote: I like it
  • +6
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it
0-2-3-6-8

6-3=3 So the longest passage is 3, not 2.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    But we have put a tower on 6 so why we are also taking 6 in answer, my point is that on 4 and 5 there will not be any tower but on 6 there will be a tower and on 3 also there will be tower too

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Got it at last. The problem is about the distance free of the traffic lights, not about the consecutive number of points free of the traffic lights and of maximum length. We can freely drive from the point 3 to the point 6 without meeting a single traffic lights.