Billy is playing with his newly bought Lego set containing
To help guide him, Billy found an old, worn out instruction manual from the bottom of his bed. The instructions give the required heights of each building block
Perplexed, Billy runs to you for help. Initially and after each of the
Constraints
Initially and after each of the
Subtask 1 [30%]
Subtask 2 [40%]
Subtask 3 [30%]
No additional constraints.
Input Specification
The first line contains
The next line contains
Each of the next
Output Specification
Initially and after each of the YES
if there exists a castle consistent with the instructions and NO
otherwise.
Sample Input
9 3
1 0 0 5 0 0 8 0 2
5 9
7 0
5 0
Sample Output
YES
NO
YES
YES
Explanation
Initially, 1 3 4 5 7 9 8 6 2
is a possible castle.
After the first revision, the instructions are 1 0 0 5 9 0 8 0 2
, which has no consistent castle.
After the second revision, the instructions are 1 0 0 5 9 0 0 0 2
, and 1 3 4 5 9 8 7 6 2
is a possible castle.
After the third revision, the instructions are 1 0 0 5 0 0 0 0 2
, which has a few possible castles.
Comments