PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: raysh07
Tester: iceknight1093
Editorialist: iceknight1093
DIFFICULTY:
Cakewalk
PREREQUISITES:
None
PROBLEM:
Chef is trying to entertain N children. He can either buy a TV for 1000 rupees and keep them all entertained, or buy one toy for each child, costing 200 rupees a toy.
Find the minimum cost needed to entertain everyone.
EXPLANATION:
Since each toy costs 200, buying one for each child will cost a total of 200\cdot N rupees.
The optimal cost is thus either this or paying 1000 for the TV, whichever is cheaper.
Thus, the answer is
\min(1000, 200\cdot N)
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
n = int(input())
print(min(1000, 200*n))