Write an algorithm that find train through the tunnel, the number of car (s) must be extra lights,
Enter the first line is N and L, the second line indicates car length, the third line said grid corresponding to the car lights on and off,
Input: the first line: 7 to 10
The second line: 5, 3, 4, 5 and 9 9 9
The third line: 1 0 0 0 1 0 0
Output: 2 (you can find a solution is a length of 4 and 9 respectively, the third and seventh car lamp)
My train of thought is a first began to turn on the light and the length is greater than or equal to L car the length of the corresponding to 0 (example: 0, 3, 4, 5 0 9 9), but the rest of the don't know what to do, between 0 hope bosses under the guidance ideas (python),
CodePudding user response: