PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: iceknight1093
Tester: sushil2006
Editorialist: iceknight1093
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
There are two payment schemes: pay 100 immediately and then X per week for the next 4 weeks; or pay 300 immediately.
Which ends up being cheaper?
EXPLANATION:
The first payment scheme has a cost of 100 initially and then X for four weeks; for a total of
100 + 4\cdot X
The second payment scheme has a constant cost of 300 coins.
The answer is the minimum of these two quantities, i.e.
\min(300, 100 + 4\cdot X)
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
x = int(input())
print(min(300, 100 + 4*x))