Олимпиадный тренинг

Задача 42838. five courses


Selena Lunar Restaurant serves the following five dishes:

Nyagao (rice cake): A minutes to serve.
Jiao (dumplings): takes B minutes to serve.
Tang (sweet rice balls): C minutes to serve.
Shiitake (stewed mushrooms): D minutes to serve.
Hanbagu (hamburger patty): takes E minutes to serve.

Let's assume that the time of serving the dish is the time between the placement of the order and the delivery of the dish.

The lunar restaurant has the following ordering policies:
  • An order can only be placed at a multiple of 10 minutes (0, 10, 20, ... minutes). 
  • Only one dish can be ordered at a time.
  • A new order cannot be placed if the dish from the previous order has not yet been delivered. But a new order can be placed exactly at the time when the dish from the previous order has been delivered.

Gromozeka arrived at this restaurant at 0 minutes. He wants to order all five courses. Determine after what minimum number of minutes the last dish will be delivered. Gromozeka can order the dishes in any order he likes, and he can order as early as 0 minutes. Time on the Moon is measured in minutes only.

Input
The program receives 5 integers A, B, C, D, E > (1 <= A, B, C, D, E <= 123). Each number on a separate line.

Imprint
Display an integer - the answer to the problem.
 
Examples
# Input Output Note
1 29
20
7
35
120

215

If we decide to order dishes in the order of Nyagao, Jiao, Tang, Hangbau, Shiitake, the earliest possible time for each order will be as follows:

Order Nyagao in 0 minutes, which will be delivered in 29 minutes. The current time will be 29 minutes.
Order Jiao in 30 minutes, which will be at the time of 50 minutes . 
Order Tan in 50 minutes, which will be delivered in 57 minutes.
Order Hanbag at time 60, which will be delivered at time 180 minutes.
Order Shiitake in 180 minutes, which will be delivered in 215 minutes.
It is not possible to order dishes in a different way so that the last dish would be delivered earlier than the one specified in the example.