Problem:


Score: 200 points

Problem Statement

The restaurant AtCoder serves the following five dishes:

ABC Don (rice bowl): takes A minutes to serve.

ARC Curry: takes B minutes to serve.

AGC Pasta: takes C minutes to serve.

APC Ramen: takes D minutes to serve.

ATC Hanbagu (hamburger patty): takes E minutes to serve.

Here, the time to serve a dish is the time between when an order is placed and when the dish is delivered.

This restaurant has the following rules on orders:

An order can only be placed at a time that is a multiple of 10 (time 0, 10, 20, ...).

Only one dish can be ordered at a time.

No new order can be placed when an order is already placed and the dish is still not delivered, but a new order can be placed at the exact time when the dish is delivered.

E869120 arrives at this restaurant at time 0. He will order all five dishes. Find the earliest possible time for the last dish to be delivered.

Here, he can order the dishes in any order he likes, and he can place an order already at time 0.

Constraints

A, B, C, D and E are integers between 1 and 123 (inclusive).

Input

Input is given from Standard Input in the following format:

A
B
C
D
E

Output

Print the earliest possible time for the last dish to be delivered, as an integer.

Sample Input 1

29
20
7
35
120

Sample Output 1

215

If we decide to order the dishes in the order ABC Don, ARC Curry, AGC Pasta, ATC Hanbagu, APC Ramen, the earliest possible time for each order is as follows:

Order ABC Don at time 0, which will be delivered at time 29.

Order ARC Curry at time 30, which will be delivered at time 50.

Order AGC Pasta at time 50, which will be delivered at time 57.

Order ATC Hanbagu at time 60, which will be delivered at time 180.

Order APC Ramen at time 180, which will be delivered at time 215.

There is no way to order the dishes in which the last dish will be delivered earlier than this.

Sample Input 2

101
86
119
108
57

Sample Output 2

481

If we decide to order the dishes in the order AGC Pasta, ARC Curry, ATC Hanbagu, APC Ramen, ABC Don, the earliest possible time for each order is as follows:

Order AGC Pasta at time 0, which will be delivered at time 119.

Order ARC Curry at time 120, which will be delivered at time 206.

Order ATC Hanbagu at time 210, which will be delivered at time 267.

Order APC Ramen at time 270, which will be delivered at time 378.

Order ABC Don at time 380, which will be delivered at time 481.

There is no way to order the dishes in which the last dish will be delivered earlier than this.

Sample Input 3

123
123
123
123
123

Sample Output 3

643

This is the largest valid case.



Sample input:
29
20
7
35
120


Sample output:
215

Submission status: Accepted

Solution code:
# coding: utf-8
minutes = [int(input()) for _ in range(5)]
time=0
l=[]
 
for i in minutes:
    time = time + i
    if(i%10==0):
        l.append(0)
    else:
        l.append(10-i%10)
 
l.sort()
time += sum(l[:-1])
print(time)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

li = [int(input()) for i in range(5)]

li2 = list()

for i in li:
    if i % 10 != 0:
        i = (i // 10 + 1) * 10
    li2.append(i)

# li3 = [i for i in li if i % 10 != 0]

li4 = [int(str(i)[-1]) for i in li if i % 10 != 0]

# print(li3, li4)

if not li4:
    print(sum(li))
else:
    print(sum(li2) - 10 + min(li4))

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

A_rest = A % 10
B_rest = B % 10
C_rest = C % 10
D_rest = D % 10
E_rest = E % 10

A_diff = 0
B_diff = 0
C_diff = 0
D_diff = 0
E_diff = 0

if A_rest != 0:
    A_diff = 10 - (A_rest)
else:
    A_rest = 10
if B_rest != 0:
    B_diff = 10 - (B_rest)
else:
    B_rest = 10
if C_rest != 0:
    C_diff = 10 - (C_rest)
else:
    C_rest = 10
if D_rest != 0:
    D_diff = 10 - (D_rest)
else:
    D_rest = 10
if E_rest != 0:
    E_diff = 10 - (E_rest)
else:
    E_rest = 10

dish_list = [A_rest,B_rest,C_rest,D_rest,E_rest]
min_rest = min(dish_list)

diff = min_rest - 10

time = A + A_diff + B + B_diff + C + C_diff + D + D_diff + E + E_diff + diff

print(time)

Submission status: Accepted

Solution code:
data = [int(input()) for _ in range(5)]
time = 0
r = []
for d in data:
    time += d
    if d % 10 == 0:
        r.append(0)
    else:
        r.append(10 - d % 10)
r.sort()
time += sum(r[:-1])
print(time)

Submission status: Accepted

Solution code:
dishes = [input() for i in range(5)]

sum_time = 0
last_order_surplus = 10

for dish in dishes:
  if last_order_surplus > int(dish) % 10 & int(dish) % 10 != 0:
    last_order_surplus = int(dish) % 10
  if int(dish) % 10 != 0:
    sum_time += int(int(dish) / 10 + 1)
  else:
    sum_time += int(int(dish) / 10)

print (sum_time * 10 + last_order_surplus - 10)

Submission status: Accepted

Solution code:
nums = [int(input()) for _ in range(5)]


def orders(nums):
  r = [10 - (num % 10) for num in nums if (num % 10)]
  if r:
  	return sum(nums) + sum(r) - max(r)
  return sum(nums)

print(orders(nums))

Submission status: Accepted

Solution code:
time = []
last = 10

for i in range(5):
    time.append(int(input()))
    if(time[i] % 10 > 0 and time[i] % 10 < last):
        last = time[i] % 10

sum = 0
for i in range(5):
    sum += time[i]
    if(time[i] % 10 != 0):
        sum += (10 - (time[i] % 10))

print(sum + last - 10)

Submission status: Accepted

Solution code:
import heapq


def solve(order_list):
    priority_queue = []
    # time O(N log(N))
    for key, order in enumerate(order_list):
        priority = (order - 1) % 10
        heapq.heappush(priority_queue, [-priority, order, key])

    sum_time = 0
    # time O(N log(N))
    while priority_queue:
        priority, order, key = heapq.heappop(priority_queue)
        if len(priority_queue) and order % 10:
            sum_time += (order // 10 + 1) * 10
        else:
            sum_time += order
    return sum_time


def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())

    ans = solve([a, b, c, d, e])
    print(ans)


main()

Submission status: Accepted

Solution code:
a = [int(input()) for _ in range(5)]
ans,mod = 0,0
for i in a:
    ans += i if i%10 == 0 else i+(10-i%10)
    mod = max(mod,i%10) if i%10 == 0 else max(mod,10-i%10)
print(ans-mod)

Submission status: Accepted

Solution code:
li=[]

for i in range(5):
    li.append(str(input()))

min=10
f=1
for i in li:
    temp=int(i[-1])
    #print('-1',temp)
    if temp!=0:
        f=0
    if min > temp and temp!=0:
        min=temp
    if f:
        min=10


sum=0
for i in li:
    #print(i[-1])
    if i[-1]!='0':
        temp=int(i[0:-1]+"0")+10
    else:
        temp=int(i)
    #print("temp", temp)
    sum+=temp

sum-=(10-min)

print(sum)

Submission status: Accepted

Solution code:
# Five Dishes
# https://atcoder.jp/contests/abc123/tasks/abc123_b

NUM_DISHES = 5
tt = 0
itvs = list()

for i in range(NUM_DISHES):
    st = int(input())
    tt += st
    if st % 10 == 0:
        itvs.append(0)
    else:
        itvs.append(10 - st % 10)

itvs.sort()

for interval in range(len(itvs) - 1):
    tt += itvs[interval]

print "{}".format(tt)

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=-(-A//10)*10
b=-(-B//10)*10
c=-(-C//10)*10
d=-(-D//10)*10
e=-(-E//10)*10
print(a+b+c+d+e-max(a-A,b-B,c-C,d-D,e-E))

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=-(-A//10)*10
b=-(-B//10)*10
c=-(-C//10)*10
d=-(-D//10)*10
e=-(-E//10)*10
print(a+b+c+d+e-max(a-A,b-B,c-C,d-D,e-E))

Submission status: Accepted

Solution code:
a = []
for i in range(5):
    a.append(int(input()))

n = a[0] % 10
if n == 0: n = 10
idx = 0
for i in range(5):
    if a[i] % 10 == 0:
        continue
    else:
        if n > a[i] % 10:
            n = a[i] % 10
            idx = i

for i in range(5):
    if i != idx and a[i]%10 != 0:
        a[i] = (a[i] // 10) * 10 + 10

print(sum(a))

Submission status: Accepted

Solution code:
def main():
  A=int(input())
  B=int(input())
  C=int(input())
  D=int(input())
  E=int(input())

  Amod=A%10
  if Amod==0:
    Amod=10
  Bmod=B%10
  if Bmod==0:
    Bmod=10
  Cmod=C%10
  if Cmod==0:
    Cmod=10
  Dmod=D%10
  if Dmod==0:
    Dmod=10
  Emod=E%10
  if Emod==0:
    Emod=10
  last=min(Amod,Bmod,Cmod,Dmod,Emod)
  
  A_round=((A+9)//10)*10
  B_round=((B+9)//10)*10
  C_round=((C+9)//10)*10
  D_round=((D+9)//10)*10
  E_round=((E+9)//10)*10
  
  time=A_round+B_round+C_round+D_round+E_round
  time=time-10+last

  print(time)

main()

Submission status: Accepted

Solution code:
list = [int(input()) for n in range(5)]
min = 100
min_arg = 0
for i in range(5):
  if min > list[i] % 10 and list[i] % 10 != 0:
    min = list[i] % 10
    min_arg = i
ans = 0
for i in range(5):
  if i == min_arg:
    continue
  ans += list[i]
  if ans % 10 != 0:
    ans = ans - (ans % 10) + 10
ans += list[min_arg]
print(ans)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

minus = 0
ans = 0

for i in [a,b,c,d,e]:
    shou = i//10
    amari = i% 10
    if amari == 0:
        amari = 10
    minus = max(minus,10-amari)
    ans += (shou+1)*10 if amari != 10 else + shou*10
ans -= minus


print(ans)

Submission status: Accepted

Solution code:
nums = [int(input()) for i in range(5)]
maxleft = 0
m = -1
for i in range(5):
    temp = 10 - nums[i] % 10
    if temp > maxleft and temp != 10:
        maxleft = temp
        m = i

total = 0
for i in range(5):
    if i != m and nums[i] % 10 != 0:
        total += nums[i] - nums[i] % 10 + 10
    else:
        total += nums[i]
print(total)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

sample_list = []
sample_list.append(a)
sample_list.append(b)
sample_list.append(c)
sample_list.append(d)
sample_list.append(e)

x = []
for i in sample_list:
  if i%10 == 0:
    x.append(0)
  else:
    x.append(10-(i%10))

print(sum(sample_list)+sum(x)-max(x))

Submission status: Accepted

Solution code:
a =int(input())
b =int(input())
c =int(input())
d =int(input())
e =int(input())
sample_list = []
sample_list.append(a)
sample_list.append(b)
sample_list.append(c)
sample_list.append(d)
sample_list.append(e)
x = []
for i in sample_list:
  if i%10 == 0:
    x.append(0)
  else:
    x.append(10-(i%10))
print(sum(sample_list)+sum(x)-max(x))

Submission status: Accepted

Solution code:
# TODO B - Five Dishes
# https://atcoder.jp/contests/abc123/tasks/abc123_b

NUM_DISHES = 5
intervals = list()

total_time = 0
for i in range(NUM_DISHES):
    serve_time = int(input())
    total_time += serve_time

    if serve_time % 10 == 0:
        intervals.append(0)
    else:
        intervals.append(10 - serve_time % 10)

intervals.sort()

for interval in range(len(intervals) - 1):
    total_time += intervals[interval]

print "{:d}".format(total_time)

Submission status: Accepted

Solution code:
from math import ceil
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

def f(S,v):
    if S:
        res = []
        for i in range(len(S)):
            res += f(S[:i] + S[i+1:], 10 * ceil(v / 10) + S[i])
        return res
    else:
        return [v]
ans = min(f([a,b,c,d,e],0))
print(ans)

Submission status: Accepted

Solution code:
from functools import reduce
def dishes(a,b,c,d,e):
    s = [a,b,c,d,e]
    k = list(map(lambda x:(int(x/10)+1)*10 if x%10 != 0 else (int(x/10))*10,s))
    x = [k[i] - s[i] for i in range(len(s))]
    i = x.index(max(x))
    k.remove(k[i])
    k.append(s[i])
    ans = reduce(lambda x,y:x + y,k)
    return ans

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
print(dishes(a,b,c,d,e))

Submission status: Accepted

Solution code:
a =int(input())
b =int(input())
c =int(input())
d =int(input())
e =int(input())
sample_list = []
sample_list.append(a)
sample_list.append(b)
sample_list.append(c)
sample_list.append(d)
sample_list.append(e)
x = []
for i in sample_list:
    if i % 10 == 0:
        x.append(0)
    else:
        x.append(10-(i%10))
print(sum(sample_list)+sum(x)-max(x))

Submission status: Accepted

Solution code:
l = []
x = []
for i in range(5):
    l.append(int(input()))
for i in l:
    if i % 10 == 0:
        x.append(0)
    else:
        x.append(10-(i%10))
print(sum(l)+sum(x)-max(x))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = 0
g = 0
h = 0
i = 0
j = 0
for k in range(9):
    if (a + f) % 10 != 0:
        f += 1
    if (b + g) % 10 != 0:
        g += 1
    if (c + h) % 10 != 0:
        h += 1
    if (d + i) % 10 != 0:
        i += 1
    if (e + j) % 10 != 0:
        j += 1
print(a+b+c+d+e+f+g+h+i+j-max(f,g,h,i,j))

Submission status: Accepted

Solution code:
import math
a=[input() for i in range(5)]
nzero=['99999']
for i in a:
    if i[-1]!='0':
        nzero+=[i[-1]]
ans=sum([math.ceil(int(i)/10)*10 for i in a])
h=min(nzero)

if h=='99999':
    print(ans)
else:
    print(ans-10+int(h))

Submission status: Accepted

Solution code:
X = [int(input()) for i in range(5)]
XX = []

ans = 0

deff = 0


def define(x):
    return ((x + 9) // 10) * 10 - x


for i in X:
    # // で切り捨てできるっぽい
    f = (i + 9) // 10
    f *= 10
    XX.append(f)


deff = max(define(int(X[0])), define(int(X[1])), define(int(X[2])), define(int(X[3])), define(int(X[4])))


for i in XX:
    ans += i


print(ans - deff)

Submission status: Accepted

Solution code:
l = []
for i in range(5):
    l.append(int(input()))

lsum = sum([int((i-1) // 10) * 10 + 10 for i in l])
lmin = 9 - min([(i-1) % 10 for i in l])

print(lsum - lmin)

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
 
l = [A, B, C, D, E]
d = []
 
for i in l:
    if i % 10 == 0:
        d.append(0)
    else: 
        d.append(10 - (i % 10))
 
print(sum(l) + sum(d) - max(d))

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

minutes = [A, B, C, D, E]
diff = []

for i in minutes:
    if i % 10 == 0:
        diff.append(0)
    else: diff.append(10 - (i % 10))

print(sum(minutes) + sum(diff) - max(diff))

Submission status: Accepted

Solution code:
time=0
list1=[int(input()) for i in range(5)]
list2=[]
for i in range(5):
    tmp=0
    for j in range(5):
        if i==j or list1[j]%10==0:
            tmp+=list1[j]
        else:
            tmp+=(list1[j]-list1[j]%10+10)
    list2.append(tmp)
print(min(list2))

Submission status: Accepted

Solution code:
#2
import numpy as np
line = np.zeros([5,],dtype=np.int)
for i in range(0,5):
    line[i] = int(input())

line_k = line%10
#print(line_k)

last_one=0
last_one_min=10
for l in range(0,5):
    if (line_k[l]>0):
        if last_one_min>line_k[l]:
            last_one_min=line_k[l]
            last_one=l
#print(last_one)
count = 0
for j in range(0,5):
    if j==last_one:
        count+=line[j]
    else:
        if line_k[j]==0:
            count+=line[j]
        else:
            count+=10*(line[j]//10) + 10
print(count)

Submission status: Accepted

Solution code:
L = [int(input()) for i in range(5)]
longmenuindex=0
for i in range(len(L)):
    if(L[i]%10<L[longmenuindex]%10 and L[i]%10!=0):
        longmenuindex = i
time=0
for i in range(len(L)):
    if(i != longmenuindex):
        if(L[i]%10!=0):
            time += (L[i]+(10-L[i]%10))
        else:
            time += L[i]
print(time+L[longmenuindex])

Submission status: Accepted

Solution code:
List = []
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))

L = [x % 10 if x % 10 != 0 else 10 for x in List]
last_item = L.index(min(L))

# Find the next multiple of 10 for each value, except the last item
for i in range(len(List)):
    if (List[i] % 10) and i != last_item:
        List[i] = List[i] + (10 - List[i] % 10)

print(sum(List))

Submission status: Accepted

Solution code:
abc = int(input())
arc = int(input())
agc = int(input())
apc = int(input())
atc = int(input())

num_list = [abc, arc, agc, apc, atc]

def fn(num):
  if num % 10 == 0:
    return 0
  else:
    return 10 - num % 10

num_list_res = [fn(num) for num in num_list]
max_idx = num_list_res.index(max(num_list_res))

ans = 0
for i in range(len(num_list)):
  if i == max_idx:
    ans += num_list[i]
  else:
    ans += num_list[i] + num_list_res[i]
print(ans)

Submission status: Accepted

Solution code:
L=[]
M=[0]
for i in range(5) :
  A=int(input())
  L.append(A)
  if A%10!=0 :
    M.append(10-A%10)
print(sum(L+M)-max(M))

Submission status: Accepted

Solution code:
from math import ceil 
L=[]
X=0
M=int(input())
L.append(M)
for i in range(4) :
  A=int(input())
  L.append(A)
  if A%10 < M%10 and A%10!=0 :
    M=A
L.remove(M)
for i in L :
  X+=ceil(i/10)*10
print(X+M)

Submission status: Accepted

Solution code:
t=list(map(int,open(0)))
def divideten(x): 
	if x%10==0:
		return 10
	else: 
		return x%10
u=sorted(map(divideten,t))
def kiriage(x):
	if x%10==0:
		return x
	else:
		return x+10-(x%10)
v=list(map(kiriage,t))
print(sum(v)+min(u)-10)

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10

list_1 = [A, B, C, D, E]
list_2 = [a, b, c, d, e]
list_2_2 = []
for x in list_2:
    if x != 0:
        list_2_2.append(x)
if list_2_2 != []:
	smallest = min(list_2_2)
else:
  	smallest = 10

list_3 = []

count = 0
for i in range(5):
    if list_2[i] == smallest and count % 10 == 0:
        list_3.append(list_1[i])
    elif list_2[i] != 0:
        list_3.append(list_1[i] - list_2[i] + 10)
    else:
        list_3.append(list_1[i])
    count += list_3[i]

sum = 0
for x in list_3:
    sum += x
    
print(sum)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

ABCDE = [int(input()) for i in range(5)]

e = min(map(lambda x: (x - 1) % 10 + 1, ABCDE))
s = list(map(lambda x: int((x - 1) / 10) * 10 + 10, ABCDE))
print(sum(s) - (10 - e))

Submission status: Accepted

Solution code:
import math

# 定義
minutes = [int(input()) for i in range(5)]
m = [math.ceil(minutes[k] / 10) * 10 for k in range(5)]

# 最後に注文するやつを決める
last = min((minutes[l] - 1) % 10 for l in range(5))
last += 1

#　出力
print(m[0] + m[1] + m[2] + m[3] + m[4] + last - 10)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
s = [a, b, c, d, e]
u = []
v = []
ans = 0

for i in range(len(s)):
    if s[i] % 10 == 0:
        ans += s[i]
    else:
        u.append(s[i])
        v.append(s[i] % 10)

if len(v) != 0:
    k = min(v)
    for j in range(len(u)):
        ans += u[j] + 10 - v[j]
        
    ans = ans - 10 + k
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
time_list = [int(input()) for i in range(5)]
amari = []

for i in range(5):
    amari.append([time_list[i] // 10, time_list[i] % 10])
    
small = 9
number = 0
for i in range(5):
    if amari[i][1] > 0 and amari[i][1] < small:
        small = amari[i][1]
        number = i
        
total_time = 0
for i in range(5):
    if i != number:
        if amari[i][1] == 0:
            total_time += amari[i][0] * 10
        else:
            total_time += amari[i][0] * 10 + 10
    else:
        total_time += time_list[i]
        
print(total_time)

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

times = [A, B, C, D, E]

def calRest(times):
	rest = 10
	for time in times:
		if time % 10 == 0:
			continue
		elif time % 10 < rest:
			rest = time % 10
	return 10 - rest

sumTime = sum([10 * (int((time-1)/10)+1) for time in times])
rest = calRest(times)
neatTime = sumTime - rest
print(neatTime)

Submission status: Accepted

Solution code:
a=[int(input()) for i in range(5)]
minn,summ=10,0
for i in a:
  minn=min(minn,(i-1)%10)
  summ+=(i+9)//10
print(summ*10+minn-9)

Submission status: Accepted

Solution code:
def deltime(x):
    return (int((x+9)/10))*10

def subtime(x):
    return deltime(x)-x

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

sumtime=deltime(a)+deltime(b)+deltime(c)+deltime(d)+deltime(e)
sumtime -= max([subtime(a),subtime(b),subtime(c),subtime(d),subtime(e)])

print(sumtime)

Submission status: Accepted

Solution code:
import math

nums = []
last_pos = 0
total = 0

def score(n):
    # 1, 2, 3, ... 9, 0
    if n % 10 == 0:
        return 10
    return n % 10

def ceil(n):
    return math.ceil(n / 10) * 10

for i in range(5):
    t = int(input())
    nums.append(t)
    if score(t) < score(nums[last_pos]):
        last_pos = i

for i in range(5):
    if i == last_pos:
        continue
    total += ceil(nums[i])

total += nums[last_pos]

print(total)

Submission status: Accepted

Solution code:
def abc(n):
    if n % 10 == 0:
        return n
    else:
        return n + 10 - (n%10)

ans = 0
mods = []

for _ in range(5):
    tmp = int(input())
    ans += abc(tmp)
    mods.append(tmp%10)

if not set(mods) == {0}:
    while 0 in mods:
        mods.remove(0)
    ans -= 10
    ans += min(mods)

print(ans)

Submission status: Accepted

Solution code:
lists = []
lists2 = []
a = int(input())
if a %10 == 0:
    lists2.append(a)
else:
    lists.append(a)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
time = 0
for t in lists2:
    time += t
for t in lists[0:len(lists)-1]:
    time += (10 - t%10) + t
if len(lists) >= 1:
    time +=lists[-1]
print(time)

Submission status: Accepted

Solution code:
atoe =[int(input()),int(input()),int(input()),int(input()),int(input())]

maxNum = 5
wrap = 0
atoe = sorted(atoe, key=lambda x: -10 if x%10==0 else -(x%10))
for i in range(0, maxNum-1):
    if atoe[i] % 10 == 0:
        step = atoe[i]
    else:
        step = (atoe[i] // 10 + 1) * 10
    #print(atoe[i], step)
    wrap += step

wrap += atoe[maxNum-1]
print(wrap)

Submission status: Accepted

Solution code:
data = [int(input()) for i in range(5)]
data.sort(key = lambda x : x % 10)
data_rev = []
first_10multiple = True
for d in data:
    if d % 10 == 0:
        data_rev.append(d)
    elif first_10multiple == True:
        data_rev.append(d)
        first_10multiple = False
    else:
        data_rev.append(d + 10 - d % 10)
print(sum(data_rev))

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]

b = [i % 10 if i % 10 != 0 else 10 for i in a]

sum = sum(((i-1)//10+1)*10 if j != b.index(min(b)) else i for j,i in enumerate(a))

print(sum)

Submission status: Accepted

Solution code:
# X = [29, 20, 7, 35, 120]
# X = [101, 86, 119, 108, 57]
# X = [123, 123, 123, 123, 123]

X = []

for _ in range(5):
    X.append(int(input()))  # S += [input()] とも書ける


a = 9
last_i = 0
for i, j in enumerate(X):
    num1 = int(str(j)[-1])

    if 0 < num1 < a:
        a = num1
        last_i = i

res = []
for x, y in enumerate(X):
    if x == last_i or y % 10 == 0:
        res.append(y)
    else:
        m = 10 - int(str(y)[-1])
        # print(m)
        res.append(y + m)
# print(res)
print(sum(res))

Submission status: Accepted

Solution code:
import math
dishes = [int(input()) for _ in range(5)]
lead_times = [int(math.ceil(t/10))*10 - t for t in dishes]
max_idx = lead_times.index(max(lead_times))
result = 0
for i in range(5):
  result += dishes[i]
  if i != max_idx:
    result += lead_times[i]
print(result)

Submission status: Accepted

Solution code:
L = []
for _ in range(5):
    L.append(int(input()))

#print('L is ', L)

m = 10
t = 0
for a in L:
    mod = a % 10
    if mod == 0:
        t = t + a
    else:
        t = t + (a // 10 + 1) * 10
        m = min(m, (a % 10))

if m == 10:
    print(t)
else:
    print(t - 10 + m)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#注文してから料理が届くまでの時間
Time = []
for i in range(5):
    a = int(input())
    Time.append(a)

#注文してから次の注文が出来るまでの時間
nextTime = list(map(lambda x: (x+9)//10*10, Time))

#bestに最短時間を代入
best = 10**5
sum = 0
for i in range(5):
    for j in range(5):
        if i == j:
            sum = sum + Time[j] 
        else:
            sum = sum + nextTime[j]
    best = min(best, sum)
    sum = 0

print(best)

Submission status: Accepted

Solution code:
list = [int(input()) for i in range(5)]
ans = 0
amari = []
for i in range(5):
  ans += (list[i] // 10) * 10
  amari.append(list[i] % 10)
amari = sorted(amari)
for i in range(5):
  if amari[i] != 0:
    ans += amari[i]
    ans += (5-(i+1)) * 10
    break
print(ans)

Submission status: Accepted

Solution code:
b = []
r = []

for _ in range(5):
  a = int(input())
  b.append((a // 10) * 10)
  r.append(a % 10)

ans = sum(b)
r.sort()

x = 10
count = 0
for _, ele in enumerate(r):
  if ele > 0:
    x = ele
    break
  count += 1
  
ans += (x + (4 - count) * 10)

print(ans)

Submission status: Accepted

Solution code:
s=[int(input()) for _ in range(5)]
k=[s[i]%10 for i in range(5)]
l=[]
for i in range(5):
    if k[i] !=0:
        l.append(10-k[i])
    else:
        l.append(0)
p=max(l)
m=sum(s)
n=sum(l)
print(int(m+n-p))

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
a = int(0.1*(9+A))
b = int(0.1*(9+B))
c = int(0.1*(9+C))
d = int(0.1*(9+D))
e = int(0.1*(9+E))
t_1 = 10*(a+b+c+d) + E
t_2 = 10*(b+c+d+e) + A
t_3 = 10*(c+d+e+a) + B
t_4 = 10*(d+e+a+b) + C
t_5 = 10*(e+a+b+c) + D
print(min([t_1,t_2,t_3,t_4,t_5]))

Submission status: Accepted

Solution code:
*a,=map(int,open(0));b=[(i+9)//10*10for i in a];s=sum(b)
print(min(s-b[i]+a[i]for i in range(5)))

Submission status: Accepted

Solution code:
a = int(input(''))
b = int(input(''))
c = int(input(''))
d = int(input(''))
e = int(input(''))
list_i = [a,b,c,d,e]
 
min_n = list_i[0] % 10
v = 0
count = 0
 
for i in range(len(list_i)):
 if list_i[i] % 10 < min_n and list_i[i] % 10 != 0:
  count = i
 
for i in range(len(list_i)):
 if i == count or list_i[i] % 10 == 0:
  v = v + list_i[i]
 else:
  v = v + list_i[i] + ( 10 - list_i[i] % 10)
 
print v

Submission status: Accepted

Solution code:
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
aa = math.ceil(a/10)*10
bb = math.ceil(b/10)*10
cc = math.ceil(c/10)*10
dd = math.ceil(d/10)*10
ee = math.ceil(e/10)*10
lista = [a, bb, cc, dd, ee]
listb = [aa, b, cc, dd, ee]
listc = [aa, bb, c, dd, ee]
listd = [aa, bb, cc, d, ee]
liste = [aa, bb, cc, dd, e]
suma = sum(lista)
sumb = sum(listb)
sumc = sum(listc)
sumd = sum(listd)
sume = sum(liste)
print(min(suma, sumb, sumc, sumd, sume))

Submission status: Accepted

Solution code:
time = [int(input()) for i in range(5)]
total = 0
min = 10
index = 0

for i in range(5):
    if (min > time[i] % 10 and time[i] % 10 != 0):
        min = time[i] % 10
        index = i
if min < 10:
    max = time[index]
    time.pop(index)

for i in range(len(time)):
    while total % 10 != 0:
        total += 1
    total += time[i]

if min < 10:
    while total % 10 != 0:
        total += 1
    total += max

print(total)

Submission status: Accepted

Solution code:
# B - Five Dishes
import math

price = []

for i in range(5):
    price.append(int(input()))

kiriage = [10*(math.ceil(i/10)) for i in price]

amari = [i%10 for i in price]


if max(amari) == 0:
    print(sum(kiriage))

else:
    while min(amari) == 0:
        amari.remove(0)

    print(sum(kiriage)-10+ min(amari))

Submission status: Accepted

Solution code:
a = int(input())
b= int(input())
c = int(input())
d = int(input())
e = int(input())
l = [] 
for i in [a,b,c,d,e]:
    if i % 10 != 0: 
        l.append(i//10*10+10-i)
print(sum([a,b,c,d,e])+sum(sorted(l)[:-1]))

Submission status: Accepted

Solution code:
from itertools import permutations
def solve(perm):
  t = 0
  for i in perm:
    t = ((t + 9) // 10) * 10
    t += x[i]
  return t

x = [int(input()) for _ in range(5)]
ans = min([solve(perm) for perm in permutations([i for i in range(len(x))])])
print(ans)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
list=[a,b,c,d,e]
worst=10
flag=0
ans=0
for i in range(5):
  if list[i]%10 != 0:
    if list[i]%10 < worst:
      worst = list[i]%10
      flag=i
for i in range(5):
  if i == flag:
    ans += list[i]
  elif list[i]%10 == 0:
    ans += list[i]
  else:
    ans += (list[i] + 10-list[i]%10)
print(ans)

Submission status: Accepted

Solution code:
l = [int(input()) for i in range(5)]
l_0 = [a%10 for a in l]
ar = []
for n in l_0:
  if n != 0:
    ar.append(10-n)
  else:
    ar.append(0)
s = ar.index(max(ar))
ar.pop(s)
ans = sum(l) + sum(ar)
print(ans)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())


ar = [t % 10 for t in [a, b, c, d, e] if t % 10 != 0]
if len(ar) == 0:
    ar.append(0)
mi = min(ar)


# print(mi)

# print([wt + (10 - (wt % 10)) if wt % 10 != 0 else wt for wt in [a, b, c, d, e]])
w = sum([wt + (10 - (wt % 10)) if wt % 10 != 0 else wt for wt in [a, b, c, d, e]])

if mi > 0:
    w = w - 10 + mi
print(w)

Submission status: Accepted

Solution code:
import numpy as np

X = np.array([int(input()) for i in range(5)])

last = -100
last_idx = -100
for i in range(len(X)):
    if X[i]%10 == 0:
        c = -1
    else:
        c = 10 - X[i]%10

    if c > last:
        last_idx = i
        last = c

X_max = X[last_idx]
X = np.delete(X, last_idx)

ans = 0
for x in X:
    if x%10 == 0:
        ans += x
    else:
        ans += (x//10)*10 + 10
ans += X_max

print(ans)

Submission status: Accepted

Solution code:
import math
import sys

ts = [int(i) for i in sys.stdin.read().strip().split('\n')]
ds = [int(math.ceil(t / 10) * 10) - t for t in ts]
ans = sum(ts) + sum(ds) - max(ds)
print(ans)

Submission status: Accepted

Solution code:
def main():
    x = [int(input()) for _ in range(5)]
    print(solve(x))

def solve(x):
    y = sorted(x, key=gap, reverse=True)
    s = sum(ceil(i) for i in y[1:])
    return s + y[0]

def ceil(x):
    r = x % 10
    if r != 0:
        return x + 10 - r
    else:
        return x

def gap(x):
    r = x % 10
    if r != 0:
        return 10 - r
    else:
        return 0

main()

Submission status: Accepted

Solution code:
L = []
for i in range(5):
    L.append(int(input()))

import math
Lc = []
L_subtract = []
for i in range(len(L)):
    Lc.append(math.ceil(L[i]/10)*10)
    L_subtract.append(Lc[i]-L[i])
print(sum(Lc) - max(L_subtract))