e-olymp 7337. Discounts

Task

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.

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

Code

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.

Links

The task at e-olymp
The decision code at ideone

One thought on “e-olymp 7337. Discounts

  1. — В таком виде программа на e-olymp не зайдет.
    — Когда Вы уже определитесь брать ли в фигурные скобки единственный оператор? Мы уже полтора года обсуждаем, что оба способа разумны. Но Вы их совершенно непредсказуемо смешиваете. Мне кажется в Вашем коде они ни к чему.

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

Ваш адрес email не будет опубликован. Обязательные поля помечены *