CF1574B.Combinatorics Homework

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given four integer values aa , bb , cc and mm .

Check if there exists a string that contains:

  • aa letters 'A';
  • bb letters 'B';
  • cc letters 'C';
  • no other letters;
  • exactly mm pairs of adjacent equal letters (exactly mm such positions ii that the ii -th letter is equal to the (i+1)(i+1) -th one).

输入格式

The first line contains a single integer tt ( 1t1041 \le t \le 10^4 ) — the number of testcases.

Each of the next tt lines contains the description of the testcase — four integers aa , bb , cc and mm ( 1a,b,c1081 \le a, b, c \le 10^8 ; 0m1080 \le m \le 10^8 ).

输出格式

For each testcase print "YES" if there exists a string that satisfies all the requirements. Print "NO" if there are no such strings.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).

输入输出样例

  • 输入#1

    3
    2 2 1 0
    1 1 1 1
    1 2 3 2

    输出#1

    YES
    NO
    YES

说明/提示

In the first testcase strings "ABCAB" or "BCABA" satisfy the requirements. There exist other possible strings.

In the second testcase there's no way to put adjacent equal letters if there's no letter that appears at least twice.

In the third testcase string "CABBCC" satisfies the requirements. There exist other possible strings.

首页