A. Domino on Windowsill | Edu Round #106 Div.2

LONGNEW·2021년 8월 13일
0

CP

목록 보기
81/155

https://codeforces.com/contest/1499/problem/A
시간 1초, 메모리 256MB

input :

  • t (1 ≤ t ≤ 3000)
  • n k1 k2 (1 ≤ n ≤ 1000; 0 ≤ k1, k2 ≤ n)
  • w b (0 ≤ w, b ≤ n).

output :

  • For each test case, print YES if it's possible to place all w+b dominoes on the board and NO, otherwise.
    각 테스트 케이스에서 w + b개의 도미노를 놓을 수 있는 경우에는 "YES"를 그렇지 않은 경우에는 "NO"를 출력하시오.

조건 :

  • 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.
    첫번째 행의 k1열 까지, 두번째 행의 k2열까지의 모든 무늬들은 흰색을 띈다. 그 외의 것들은 검정색이다.

  • 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).
    w개의 흰색 도미노가 있고 b개의 검정색 도미노가 있다.


일단 검은색 타일과 흰색 타일의 개수를 알아야 한다. 그리고 이 개수와 타일에 놓아줄 무늬들의 개수를 비교하면 된다.

어차피 짝수개의 타일들이 있다면 이 보다 작은 개수의 도미노들은 놓을 수 있을것이기에 이것만 비교해주면 되는 거다.

import sys

for _ in range(int(sys.stdin.readline())):
    n, k1, k2 = map(int, sys.stdin.readline().split())
    w, b = map(int, sys.stdin.readline().split())

    white = k1 + k2
    black = 2 * n - white

    print("YES" if white >= w * 2 and black >= b * 2 else "NO")

0개의 댓글