PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: notsoloud
Testers: iceknight1093, yash_daga
Editorialist: iceknight1093
DIFFICULTY:
TBD
PREREQUISITES:
None
PROBLEM:
Alice, Bob, and Charlie have X, Y, Z chocolates respectively.
Can these chocolates be distributed among them so that everyone has \gt 0 chocolates, and no two have the same number?
EXPLANATION:
There are a total of X+Y+Z chocolates.
Everyone wants at least one, and the number of chocolates must be distinct.
The smallest triplet following these conditions is (1, 2, 3) for a total of 6 chocolates.
So, if X+Y+Z \leq 5, the answer is immediately No
.
On the other hand, if X+Y+Z \geq 6, the answer is always Yes
:
- Give 1 chocolate to Alice
- Give 2 to Bob
- Give all the remaining to Charlie. Since there are at least 6 in total, Charlie will have \geq 3 chocolates and the conditions are satisfied.
TIME COMPLEXITY:
\mathcal{O}(N) per testcase.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
x, y, z = map(int, input().split())
print('Yes' if x+y+z >= 6 else 'No')