e-olymp 7337. Discounts


In the supermarket of electronics, if you believe in TV commercials, there is a system of discounts: from two purchased goods fully paid only the cost of a higher-value product, and the other is provided free of charge. What amount of money is enough to pay for the purchase of three goods, if the price of each is known.

Input data:

Three natural numbers [latex]a, b, c[/latex] are prices of three products [latex]\left(1 ≤ a, b, с ≤ 10000\right)[/latex].

Output data:

Purchase cost.


# Input data Output data
1 2 2 2 4
2 78 2 45 80
3 452 89 88 540
4 50 4 67 71
5 15 37 20 52


Solution of the problem

Algorithm: you will have to pay the highest price, so let’s find it at first and save it in the variable s. Next, you need to select the product for free receipt, which you put in a couple of the most expensive. To obtain the least amount of money, the remaining goods must be the cheapest.


The task at e-olymp
The decision code at ideone

5 thoughts on “e-olymp 7337. Discounts

Добавить комментарий