PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: iceknight1093
Tester: raysh07
Editorialist: iceknight1093
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
A game was released at midnight on September 4-th.
Chef has been playing it continuously since then. It’s now H hours past midnight on September X-th. How many hours has Chef played?
EXPLANATION:
It’s X-th September, so the full days Chef has played are September 4, 5, 6, \ldots, X-1.
That equals X-4 full days.
Since each day has 24 hours, this is 24\cdot (X-4) hours of play in total.
On top of that, Chef has also played for H hours on September X-th itself.
So, adding this in, the overall play time is
24\cdot (X-4) + H
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
x, h = map(int, input().split())
print(24*(x-4) + h)