PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: Abhinav Gupta
Testers: Nishank Suresh , Tejas Pandey
Editorialist: Nishank Suresh
DIFFICULTY:
500
PREREQUISITES:
None
PROBLEM:
Given AAA, BBB, and CCC, determine whether the average of AAA and BBB is strictly greater than CCC.
EXPLANATION:
The average of AAA and BBB is A+B2\frac{A+B}{2}2A+B. Compute this value and check whether it is greater than CCC using an if
condition.
Make sure to compute A+B2\frac{A+B}{2}2A+B using floats, since the standard /
division in most languages is integer (floor) division. You should use something like (A+B)/2.0
instead of (A+B)/2
.
TIME COMPLEXITY
O(1)\mathcal{O}(1)O(1) per test case.
CODE:
Editorialist’s code (Python)
T = int(input())
for _ in range(T):
A,B,C = map(int, input().split())
if (A+B)/2 > C:
print('yes')
else:
print('no')