TEA - EDITORIAL

PROBLEM LINK:

Contest Division 1
Contest Division 2
Contest Division 3
Contest Division 4

Setter: tejas_adm
Testers: gamegame
Editorialist: hrishik85

DIFFICULTY:

591

PREREQUISITES:

None

PROBLEM:

Chef needs to drink X liters of tea daily. Chef has a jar with Y liters of tea capacity. Each jar of tea costs Z rupees independent of how much tea has been filled in the jar. What is the minimum amount of money Chef has to pay for drinking X liters of tea?

EXPLANATION:

Kindly note that the tea vendor sells the tea per jar and not per liter. Even if the tea vendor fills the jar to half capacity, he will charge Z rupees.

If X is divisible by Y, then Chef will need (X / Y) jars of tea which will cost him (X / Y) * Z
If X is not divisible by Y, then Chef will need (X / Y) rounded up to the nearest integer jars of tea which will cost him [{math.ceil (X / Y)} * Z]

TIME COMPLEXITY:

Time complexity is O(1).

SOLUTION:

Editorialist's Solution
import math

t = int(input())
for _ in range(t):
    X, Y, Z = map(int,input().split())
    print((math.ceil(X/Y))*Z)
1 Like