Skip to content

Latest commit

 

History

History
24 lines (12 loc) · 738 Bytes

File metadata and controls

24 lines (12 loc) · 738 Bytes

Did you handle the case when $Q \leq 36$?

Each no ball gives you a free run and a free ball. Let us assume that Nikhilesh made bowler throw $x$ no balls.

His score in that case will be:

Sum of runs scored in no balls + Sum of extra runs due to no balls + Sum of runs scored in non-no balls $= x \cdot 6 + x \cdot 1 + 36$.

$\ \ \ \ \ \ \ x \cdot 6 + x \cdot 1 + 36 \geq Q$

$\implies x \cdot 7 \geq Q - 36$

$\implies \ x \geq \frac{Q - 36}{7}$

$\therefore$ Minimum value of $x = ceil(\frac{Q - 36}{7})$.

Final ans = $max(0, min_value_of_x)$