CF1574B.Combinatorics Homework
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given four integer values a , b , c and m .
Check if there exists a string that contains:
- a letters 'A';
- b letters 'B';
- c letters 'C';
- no other letters;
- exactly m pairs of adjacent equal letters (exactly m such positions i that the i -th letter is equal to the (i+1) -th one).
输入格式
The first line contains a single integer t ( 1≤t≤104 ) — the number of testcases.
Each of the next t lines contains the description of the testcase — four integers a , b , c and m ( 1≤a,b,c≤108 ; 0≤m≤108 ).
输出格式
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.