PROBLEM LINK:
Practice
Contest: Division 1
Contest: Division 2
Contest: Division 3
Contest: Division 4
Author: raysh07
Tester: sushil2006
Editorialist: iceknight1093
DIFFICULTY:
TBD
PREREQUISITES:
None
PROBLEM:
Find the minimum integer runs per over needed to score strictly more than N runs in 20 overs.
EXPLANATION:
There are a couple of solutions.
One solution is to simply try all values of R starting from 1, 2, 3, 4, \ldots
For a fixed value of R, the number of runs that can be scored is 20\cdot R.
Print the first R such that 20\cdot R \gt N.
Alternately, you can use a little math.
We need more than N runs in total, which means at least N+1 runs.
There are 20 overs, which means we need to go at a rate of at least
runs per over.
The minimum required run rate is thus just the smallest integer not smaller than \frac{N+1}{20}, i.e. the result of rounding that fraction up.
One way of computing this value is to round \frac{N}{20} down first and then add 1 to it.
TIME COMPLEXITY:
\mathcal{O}(1) per testcase.
CODE:
Editorialist's code (PyPy3)
n = int(input())
print(n//20 + 1)