308780: CF1574B. Combinatorics Homework
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Combinatorics Homework
题意翻译
给定整数 $a,b,c,m$。 求是否存在一个字符串 $s$ 满足: - $s$ 中正好有 $a$ 个字符 `A`,$b$ 个字符 `B`,$c$ 个字符 `C`,且不包含其他字符。 - **正好**存在 $m$ 个互不相同的整数 $i$ 使得 $1\leq i<n$ 且 $s_i=s_{i+1}$。 存在输出 `YES`,不存在输出 `NO`。$T$ 组数据。 保证: $1\leq T\leq 10^4;$ $1\leq a,b,c\leq10^8;0\leq m\leq10^8;$题目描述
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 \le t \le 10^4 $ ) — the number of testcases. Each of the next $ t $ lines contains the description of the testcase — four integers $ a $ , $ b $ , $ c $ and $ m $ ( $ 1 \le a, b, c \le 10^8 $ ; $ 0 \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