What is the best approach to begin with competitive programming which involves finding minimum or maximum value?

Can anyone tell me how to approach a question which involves finding minimum or maximum solution? Here is an example question that I face difficulty while solving it.

Question

Explanation of the sample statement solution

PS: I need to know the exact approach that i should always follow whenever i need to solve these kind of problems.