Sensor Blocking
Problem Statement
As usual, Seth and Andy have stayed at uni until 3am the night before their exam.
Instead of studying for their exam, they are studying the motion sensor layout of the room in order to cover the sensors with sheets of foil, so that they can continue their degeneracy with the lights off and unable to automatically turn back on.
They model the room as an array
Conveniently, MAPS has a stash of sheets of foil, with each sheet capable of covering exactly
Input
The first line contains two integers,
Output
The output consists of a single integer, the minimum number of sheets of foil required to block every sensor in the room.
Constraints
For test set 1:
For test set 2:
Sample Test Case
Example 1
Input
6 2
0 2 1 1 3 1
Output
5
Explanation
A possible solution, with lines of #
marking a sheet of foil:
0 2 1 1 3 1
# #
# #
# #
# #
# #
It can be shown that no configuration with fewer sheets can cover every sensor.
Comments