WRAPGIFTS - Editorial

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4

Author: notsoloud
Tester: mexomerf
Editorialist: iceknight1093

DIFFICULTY:

cakewalk

PREREQUISITES:

None

PROBLEM:

How many gifts with dimensions H\times L\times W can be fully wrapped with 1000 square centimeters of wrapping paper?

EXPLANATION:

Each gift has a surface area of 2\cdot (HW + HL + WL).
Let A denote this surface area.

With 1000 square centimeters of wrapping paper, the maximum number of gifts that can be wrapped is exactly:

\left\lfloor \frac{1000}{A} \right\rfloor

Here, \left\lfloor \ \ \right\rfloor denotes the floor function, i.e., \left\lfloor x \right\rfloor is the largest integer that doesn’t exceed x.

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
for _ in range(int(input())):
    h, l, w = map(int, input().split())
    area = 2*(h*l + h*w + l*w)
    
    print(1000 // area)