PROBLEM LINK
Author: Avijit Agarwal
Tester and Editorialist: Soumik Sarkar
DIFFICULTY
Cakewalk
PREREQUISITES
None
PROBLEM
X points are required from Y matches. For each match, a loss gives 0 points, a tie gives 1 point and a win gives 2 points. Gather X points using minimum number of wins.
EXPLANATION
If X \leq Y, it is possible to tie X matches and get the required points.
If X > Y, one must win exactly X - Y matches and tie the rest.
The answer can be expressed as \max(0, X - Y).
Time complexity is \mathcal{O}(1) per case.
AUTHOR’S AND TESTER’S SOLUTIONS
Author’s solution can be found here.
Tester’s solution can be found here.