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:
Chef has X hours of free time. He can decorate his tree, bake cookies, or make a gingerbread house, taking 1, 2, and 4 hours for each of these activities respectively.
How many of the activities can be completed in X hours?
EXPLANATION:
It’s best to do the quicker activities first.
So, Chef will first decorate his tree (taking one hour), then bake cookies (taking an additional two hours), and finally make a gingerbread house (an extra four hours).
This means:
- If X \geq 7, all activities can be completed, and the answer is 3.
- If X \lt 7 but X \geq 3, the first two activities can be completed and the answer is 2.
- Otherwise, the answer is 1.
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
x = int(input())
if x >= 7: print(3)
elif x >= 3: print(2)
else: print(1)