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 $a, b, c$ are prices of three products $\left(1 ≤ a, b, с ≤ 10000\right)$.

Purchase cost.

Tests

# 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 decision code at ideone

5 thoughts on “e-olymp 7337. Discounts”

1. Данила Савчак says:

Расставь около && пробелы, чтобы не было целым текстом.

• Яна Колчинская says:

Исправила, спасибо.

• Пожалуйста, если ссылаетесь на переменные, то используйте кнопку crayone с опцией inline. Тогда в тексте и в программе обозначения будут совпадать.
• Что Вы имели в виду под cycles в ключевых словах?