All submissions for this problem are available.
Your younger brother just purchased a set of lego blocks. He built a house and now wishes to build a rectangular fence around it.
But he has only a few blocks left. Width of each block is 1 unit. Help him build the fence on the periphery of the board.
It is strictly desired that the fence has equal width at all the points equal to 1 unit.
The first line contains the dimensions of the board L and B which has to be fenced.
A number of lines follow, where each line is
in the form of N S,
where N is the number of blocks and S is the corresponding Size (Length).
Input is terminated by 0.
Output "YES" or "NO" (without the quotes) depending on whether it is possible to construct the fence with the given configuration of the blocks or not.
1 <= B <= L <= 200
0 <= N,S <= 10^4
Input: 6 4 1 6 2 3 1 4 0 Output: YES
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
Fetching successful submissions
If you are still having problems, see a sample solution here.