CHEFBAKES77 - Editorial

PROBLEM LINK:

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

Author: raysh07
Tester: sushil2006
Editorialist: iceknight1093

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

Chef has N cakes, each weighing X kilograms.
A single truck has a capacity of Y kilograms.
How many trucks are needed to transport all N cakes?

EXPLANATION:

First, we need to know the number of cakes that can fit into a single truck - let’s call this quantity C.

A single truck can hold Y kilograms, so with each cake weighing X kilograms, the number of cakes that can fit into one truck equals

C = \left\lfloor \frac{Y}{X} \right\rfloor

With at most C cakes in a single truck, to fit N takes we’ll need

\left\lceil \frac{N}{C} \right\rceil

trucks.

Here,

  • \left\lfloor \ z\ \right\rfloor denotes the floor function, i.e. z rounded down to the nearest integer.
    For example, \left\lfloor \ 1.2\ \right\rfloor = 1, \left\lfloor \ 2.9\ \right\rfloor = 2, \left\lfloor \ 3\ \right\rfloor = 3
  • \left\lceil \ z\ \right\rceil denotes the ceiling function, i.e. z rounded up to the nearest integer.
    \left\lceil \ 1.2\ \right\rceil = 2, \left\lceil \ 2.9\ \right\rceil = 3, \left\lceil \ 3\ \right\rceil = 3

TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

CODE:

Editorialist's code (PyPy3)
n, x, y = map(int, input().split())
import math
per_vehicle = math.floor(y / x)
print(math.ceil(n / per_vehicle))