CF1499A.Domino on Windowsill
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You have a board represented as a grid with 2×n cells.
The first k1 cells on the first row and first k2 cells on the second row are colored in white. All other cells are colored in black.
You have w white dominoes ( 2×1 tiles, both cells are colored in white) and b black dominoes ( 2×1 tiles, both cells are colored in black).
You can place a white domino on the board if both board's cells are white and not occupied by any other domino. In the same way, you can place a black domino if both cells are black and not occupied by any other domino.
Can you place all w+b dominoes on the board if you can place dominoes both horizontally and vertically?
输入格式
The first line contains a single integer t ( 1≤t≤3000 ) — the number of test cases.
The first line of each test case contains three integers n , k1 and k2 ( 1≤n≤1000 ; 0≤k1,k2≤n ).
The second line of each test case contains two integers w and b ( 0≤w,b≤n ).
输出格式
For each test case, print YES if it's possible to place all w+b dominoes on the board and NO, otherwise.
You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).
输入输出样例
输入#1
5 1 0 1 1 0 1 1 1 0 0 3 0 0 1 3 4 3 1 2 2 5 4 3 3 1
输出#1
NO YES NO YES YES
说明/提示
In the first test case, n=1 , k1=0 and k2=1 . It means that 2×1 board has black cell (1,1) and white cell (2,1) . So, you can't place any white domino, since there is only one white cell.
In the second test case, the board of the same size 2×1 , but both cell are white. Since w=0 and b=0 , so you can place 0+0=0 dominoes on the board.
In the third test case, board 2×3 , but fully colored in black (since k1=k2=0 ), so you can't place any white domino.
In the fourth test case, cells (1,1) , (1,2) , (1,3) , and (2,1) are white and other cells are black. You can place 2 white dominoes at positions ((1,1),(2,1)) and ((1,2),(1,3)) and 2 black dominoes at positions ((1,4),(2,4)) ((2,2),(2,3)) .