- Joined
- Nov 5, 2024
- Messages
- 1
- Reaction score
- 0
Can anyone solve me this
We are given a street with N possible positions on which we can put a light. A single light will illuminate its own position and 2 more positions to the left and 2 more to the right of it. Our task is to illuminate the street with the minimum possible lights. Not all possible positions must contain light.
Input: The first number in the input is the number of possible positions to put a light bulb N and the length of the street M, then in the next line are the possible positions on which we can put a light.
Output: The minimum lights we need to illuminate the street.
For example:
Input
Result
n=5 m=5
for posisions 1 2 3 4 5
answer 1 lamp
n=3 m=10
for posisions 3 8 9
answer 2 lamp
We are given a street with N possible positions on which we can put a light. A single light will illuminate its own position and 2 more positions to the left and 2 more to the right of it. Our task is to illuminate the street with the minimum possible lights. Not all possible positions must contain light.
Input: The first number in the input is the number of possible positions to put a light bulb N and the length of the street M, then in the next line are the possible positions on which we can put a light.
Output: The minimum lights we need to illuminate the street.
For example:
Input
Result
n=5 m=5
for posisions 1 2 3 4 5
answer 1 lamp
n=3 m=10
for posisions 3 8 9
answer 2 lamp