PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: Tejas Pandey
Testers: Hriday, Utkarsh Gupta
Editorialist: Nishank Suresh
DIFFICULTY:
482
PREREQUISITES:
None
PROBLEM:
Given the revenue of three companies R_1, R_2, R_3, does any company have strictly higher revenue than the sum of the other two?
EXPLANATION:
There are only three cases to check:
- R_1 \gt R_2 + R_3
- R_2 \gt R_1 + R_3
- R_3 \gt R_1 + R_2
Check all three using if
conditions, then print “Yes” if any one of them is true.
A little observation can also reduce this to a single observation: the answer is “Yes” if and only if
2\cdot\max(R_1, R_2, R_3) \gt R_1+R_2+R_3
TIME COMPLEXITY
\mathcal{O}(1) per test case.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
a, b, c = map(int, input().split())
print('Yes' if 2*max(a, b, c) > a+b+c else 'No')