PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: notsoloud
Tester: yash_daga
Editorialist: iceknight1093
DIFFICULTY:
TBD
PREREQUISITES:
None
PROBLEM:
X friends, each weighing Y kg, want to use a lift.
The lift can carry at most 500 kg, and at most 8 people.
Can all the friends use it at the same time?
EXPLANATION:
For all the friends to be able to use the lift simultaneously, two conditions must hold:
- There should be at most 8 people, i.e, X \leq 8
- Their total weight must not exceed 500, i.e, X\cdot Y \leq 500
Check both conditions and print “Yes” if they’re both true and “No” otherwise.
TIME COMPLEXITY
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (Python)
for _ in range(int(input())):
x, y = map(int, input().split())
print('Yes' if x <= 8 and x*y <= 500 else 'No')