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:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
time_list = [a,b,c,d,e]
time_loss_list = [a,b,c,d,e]
loss = []
for i in range(len(time_list)):
    time_loss = 0
    while time_loss_list[i]%10 != 0:
        time_loss += 1
        time_loss_list[i]+=1
    loss.append(time_loss)
loss = sorted(loss)
print(sum(time_list) + sum(loss) - loss[-1])

Submission status: Accepted

Solution code:

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

for k in list_1:
    num_to_10 = 0
    if k % 10 == 0:
        list_2.append(0)
        continue
    while k % 10 != 0:
        k += 1
        num_to_10 += 1
    list_2.append(num_to_10)

last_dish_ind = list_2.index(max(list_2))
last_dish_time = list_1[last_dish_ind]
del list_1[last_dish_ind]
del list_2[last_dish_ind]
time = sum(list_1) + sum(list_2) + last_dish_time
print(time)

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

a = nin(5)
ans = sum(a)
m = 0
for i in range(5):
    k = abs(a[i] % 10 - 10)
    if k != 10:
        ans += k
        m = max(m, k)
ans -= m
print(ans)

Submission status: Accepted

Solution code:
import math
L = [int(input()) for _ in range(5)]
T = [math.ceil(l/10)*10-l for l in L]
print(sum(L)+sum(T)-max(T))

Submission status: Accepted

Solution code:
def ceil(src, range):
    return ((int)((src+9) / range) * range)

t=[int(input()) for _ in range(5)]
idx=0
max=0
sum=0
for i in range(5):
    if ceil(t[i],10)-t[i]>max and ceil(t[i],10)!=t[i]:
        max=ceil(t[i],10)-t[i]
        idx=i
for i in range(5):
    if i==idx:
        sum+=t[i]
    else:
        sum+=ceil(t[i],10)
print(sum)

Submission status: Accepted

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

A_1 = int(str(10-(A-int(A/10)*10))[-1])
B_1 = int(str(10-(B-int(B/10)*10))[-1])
C_1 = int(str(10-(C-int(C/10)*10))[-1])
D_1 = int(str(10-(D-int(D/10)*10))[-1])
E_1 = int(str(10-(E-int(E/10)*10))[-1])

_max = max(A_1,B_1,C_1,D_1,E_1)


print(A+B+C+D+E+A_1+B_1+C_1+D_1+E_1-_max)

Submission status: Accepted

Solution code:
a = [int(input()) for _ in range(5)]
b = [-(-e//10)*10-e for e in a]
print(sum(a)+sum(b)-max(b))

Submission status: Accepted

Solution code:
a=[]
b=[]
for _ in range(5):
    a.append(int(input()))
for i in  a:
    if i%10!=0:
        b.append(10-i%10)
if b:
             
    b.remove(max(b))
c=sum(b)
print(sum(a)+c)

Submission status: Accepted

Solution code:
meals=[]
for i in range(5):
    meals.append([i,int(input())])
for g in range(5):
    if meals[g][1]%10!=0:
        meals[g][0]=meals[g][1]%10
    else:
        meals[g][0]=10

meals.sort(reverse=True)

ans=0
for i in range(4):
    ans+=meals[i][1]+10-meals[i][0]
ans+=meals[-1][1]

print(ans)

Submission status: Accepted

Solution code:
S=[]
total=0
q=10
for i in range(5):
    a=int(input())
    S.append(a)
for i in range(5):
    if S[i]%10==0:
        total+=S[i]
    else:
        total+=(S[i]//10+1)*10
        q=min(q,S[i]%10)
print(total-(10-q))

Submission status: Accepted

Solution code:
s = 0
rests = [None]*5

for i in range(5):
    t_num = int(input())
    s += t_num
    rests[i] = (10 - (t_num % 10)) % 10 

print(s + sum(rests)- max(rests))

Submission status: Accepted

Solution code:
from itertools import permutations as p
l = [int(input()) for _ in range(5)]

ans = 1000
for i in p(range(5)):
    v = 0
    for j,k in enumerate(i):
        if j!=4:
            if l[k]%10:
                v += (l[k] - l[k]%10 + 10)
            else:
                v += l[k]
        else:
            v += l[k]
    ans = min(ans, v)

print(ans)

Submission status: Accepted

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

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




def m(y):
            if y%10 !=0:
                        return  y%10
            else:
                        return 10

a,b,c,d,e=map(k,[A,B,C,D,E])
a_list = [a,b,c,d,e]
sum_a_list = sum(a_list)

a_1,b_1,c_1,d_1,e_1=map(m,[A,B,C,D,E])
sum_a_list + min(a_1,b_1,c_1,d_1,e_1)

s=sum_a_list-10+min(a_1,b_1,c_1,d_1,e_1)
print(s)

Submission status: Accepted

Solution code:
S=[]
p=0;q=10
for i in range(5):
  a=int(input())
  S.append(a)
for i in range(5):
  if S[i]%10==0:
    p=p+S[i]
  else:
    p=p+(S[i]//10+1)*10
    q=min(q,S[i]%10)
print(p-(10-q))

Submission status: Accepted

Solution code:
import sys
import math

inputs = [int(row.split()[0]) for row in sys.stdin.readlines()]

remainder = []
for val in inputs:
    if val % 10 != 0:
        remainder.append(val % 10)
    else:
        remainder.append(9)
min_remainder_index = remainder.index(min(remainder))
last_order_time = inputs.pop(min_remainder_index)
    
order_time_sum = 0
for remaind_time in inputs:
    remind = remaind_time%10
    if remind!=0:
        current_time = remaind_time+ (10 - remaind_time%10)
    else:
        current_time = remaind_time
    order_time_sum += current_time
    
print(order_time_sum +last_order_time)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=[int(input()) for _ in range(5)]
rem=[]
for i in range(5):
    if x[i]%10 != 0:
        rem.append(10-x[i]%10)
    else:
        rem.append(0)
        
a=x[0] + rem[0]
b=x[1] + rem[1]
c=x[2] + rem[2]
d=x[3] + rem[3]
e=x[4] + rem[4]

print(a+b+c+d+e-max(rem[0],rem[1],rem[2],rem[3],rem[4]))

Submission status: Accepted

Solution code:
from itertools import permutations

lst=[int(input()) for i in range(5)]
ans=float('inf')
tmp=0

for l in list(permutations(lst)):
    for i in range(4):
        tmp+=l[i]
        if tmp%10!=0:
            k=((tmp//10)+1)*10
            tmp+=(k-tmp)
    tmp+=l[4]
    if tmp<=ans:
        ans=tmp
    tmp=0
print(ans)

Submission status: Accepted

Solution code:
n = [int(input()) for _ in range(5)]
min = 11
a = 0

if n.count(n[0]) == len(n):
    y = 0
    for i in range(len(n)-1):
        y += n[i] + (10 - n[i] % 10)
    y += n[-1]
    print(y)
    exit()


for i in range(len(n)):
    
    if not(n[i] % 10 == 0 or n[i] < 10):
        if min > n[i] % 10:
            min = n[i] % 10
            a = n[i]

for j in range(len(n)):
    
    if n[j] % 10 != 0:
        if n[j] != a:
            n[j] = n[j] + (10 - n[j] % 10)


print(sum(n))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc123/tasks/abc123_b

import math
orders = sorted([int(input()) for _ in range(5)], key=lambda x: (x - 1) % 10)
last_order = orders.pop(0)
orders = [math.ceil(x / 10) * 10 for x in orders]
print(sum(orders) + last_order)

Submission status: Accepted

Solution code:
#cited by maspy
A = [int(input()) for _ in range(5)]
 
ceiled = [(x+9)//10*10 for x in A]
can_save = [y - x for x,y in zip(A,ceiled)]

answer = sum(ceiled) - max(can_save)
print(answer)

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
time=0
menu=[A,B,C,D,E]
count=0
order=[]
kauri=[]
for i in range(5):
  if menu[i]%10==0:
      order.append(menu[i])
      count+=1
for h in range(9):
  for g in range(5):
    if menu[g]%10==9-h:
      kauri.append(menu[g])
      order.append(menu[g]+(h+1))
if  count!=5:
  order[4]=kauri[4-count]      
print(sum(order))

Submission status: Accepted

Solution code:
a=[int(input()) for i in range(5)]
p=[i%10 for i in a]
d=sorted(list(zip(p,a)))
q=-1
for x in d:
    if x[0]!=0:
        q=x[0]
        break
if q==-1:
    print(sum(a))
    exit(0)
s=[]
for x in d:
    if x[0]!=0:
        s.append((x[1]//10+1)*10)
    else:s.append(x[1])
print(sum(s)-10+q)

Submission status: Accepted

Solution code:
A=[None]*5
for i in range(5):
    A[i]= int(input())

index = -1
min = 9
for i in range(5):
    if A[i]%10!= 0 and min>=A[i]%10:
        min =A[i]%10
        index =i

def func(n):
    if n%10 == 0:
        return n
    else:
        return ((n//10)+1)*10
sum = 0
for i in range(5):
    if i!=index:
        sum+=func(A[i])
    else:
        sum+=A[i]
print(sum)

Submission status: Accepted

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


def main():
    ABCDE = [int(input()) for _ in range(5)]
    X = [-(-x // 10) * 10 for x in ABCDE]
    print(sum(X) - max([x - a for a, x in zip(ABCDE, X)]))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
cooks = [int(input()) for _ in range(5)]
sorted_cooks = sorted(cooks, key=lambda x: int(str(x)[-1]))
ans = 0
last_order = False
for i in range(len(sorted_cooks)):
  if(last_order == False and int(str(sorted_cooks[i])[-1]) != 0 ):
    ans += sorted_cooks[i]
    last_order = True
  else:
    ans += math.ceil(sorted_cooks[i] / 10) * 10

print(ans)

Submission status: Accepted

Solution code:
a = list()
for i in range(5):
    a.append(int(input()))
x, y = 0,float("inf")
for i in range(5):
    p = int(str(a[i])[-1])
    if p == 0:
        pass
    elif p < y:
        x = i
        y = p
for i in range(5):
    if i == x:
        pass
    elif not str(a[i])[-1] == "0":
        a[i] = (a[i]//10+1)*10
print(sum(a))

Submission status: Accepted

Solution code:
s = []
ans = 0
for i in range(5):
    n = int(input())
    m = n % 10
    ans += n
    if m != 0:
        s.append(m)
s.sort()
for i in range(len(s)):
    if i != 0:
        c = 10 - s[i]
        ans += c
print(ans)

Submission status: Accepted

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

    ans = 0

    num_list = [a,b,c,d,e]

    min_num = 10
    for i in num_list:
        if i % 10 < min_num and i % 10 != 0:
            min_num = i % 10
        if i % 10 == 0:
            ans += i
        else:
            ans += i + ( 10 - i % 10 )

    print(ans-10+min_num)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
price=[int(input()) for i in range(5)]
price.sort(key=lambda i:-i%10)
ans=0
for i in range(4):
  ans+=math.ceil(price[i]/10)*10
ans+=price[4]
print(ans)

Submission status: Accepted

Solution code:
l1 = [int(input()) for _ in range(5)]
l2 = [0] * 5
flag = 10
idx = -1

for i in range(5):
    l2[i] = l1[i] % 10
    if l2[i] != 0 and l2[i] < flag:
        flag = l2[i]
        idx = i
for j in range(5):
    if j == idx:
        continue
    while l1[j] % 10 != 0:
        l1[j] += 1
print(sum(l1))

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
max = 0
for i in range(5):
    if a[i]%10!=0 and a[max]%10>a[i]%10:
        max = i
ans = 0
for i in range(5):
    if max==i:
        ans += a[i]
    else:
        ans += -(-a[i]//10)*10
print(ans)

Submission status: Accepted

Solution code:
d=[]

for i in range(5):
    s=int(input())
    if s%10 == 0:
        d.append((s,s,s%10))
    else:
        d.append((s,s+(10-s%10),10-s%10))

d.sort(key=lambda d:d[2])
result=0
result=sum(d[i][1] for i in range(len(d)-1)) + d[-1][0]

print(result)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst = [a,b,c,d,e]

lst2 = []

for x in lst:
    amari = x % 10
    if amari == 0:
        pass
    else:
        lst2.append(10 - amari)

if not lst2:
    pass
else:
    lst2.remove(max(lst2))
print(sum(lst)+sum(lst2))

Submission status: Accepted

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

a.sort(key=lambda x:-(((x%10)+9)%10))
ans = 0
for i in range(4):
    ans += ((a[i]+9)//10)*10
ans += a[-1]
print(ans)

Submission status: Accepted

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


def tanuki(dishes):
    sum_dishes = 0
    last_dish = 0
    last_tmp = 0
    for dish in dishes:
        tmp = 10 - int(dish[-1])
        dish = int(dish)
        if tmp == 10:
            sum_dishes += dish
        elif tmp > last_tmp:
            sum_dishes += last_dish + last_tmp
            last_dish = dish
            last_tmp = tmp
        else:
            sum_dishes += dish + tmp
    return sum_dishes + int(last_dish)


print(tanuki(dishes))

Submission status: Accepted

Solution code:
N = [int(input()) for _ in range(5)]
chk = [(10 - N[i] % 10) % 10 for i in range(5)]
print(sum(N) + sum(chk) - max(chk))

Submission status: Accepted

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

t = []
for i in range(5):
    d = m[i] % 10
    o = m[i] // 10 * 10
    if d != 0:
        o += 10
    else:
        d = 10
    t.append([d, o, m[i]])

t.sort()
ans = t[0][2]
for i in range(1, 5):
    ans += t[i][1]

print(ans)

Submission status: Accepted

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


def tanuki(dishes):
    if all([i[-1] == '0' for i in dishes]):
        return sum([int(i) for i in dishes])

    sum_dishes = 0
    last_dish = 0
    last_tmp = 0
    for idx, dish in enumerate(dishes):
        tmp = 10 - int(dish[-1])
        dish = int(dish)
        if tmp == 10:
            sum_dishes += dish
        elif tmp > last_tmp:
            sum_dishes += last_dish + last_tmp
            last_dish = dish
            last_tmp = tmp
            last_idx = idx
        else:
            sum_dishes += dish + tmp
    return sum_dishes + int(dishes[last_idx])


print(tanuki(dishes))

Submission status: Accepted

Solution code:
import itertools
def permutation_all(seq, choice):
    return list(itertools.permutations(seq, choice))

a = []
for i in range(5):
    a.append(int(input()))
p = permutation_all(a,5)
ans = 1000000000
for i in range(len(p)):
    point = p[i]
    tot = 0
    for j in range(5):
        if j != 4:
            tot += (point[j]+9)//10 * 10
        else:
            tot += point[j]
    ans = min(ans,tot)
print(ans)

Submission status: Accepted

Solution code:
from math import ceil
from itertools import permutations

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

s = [a, b, c, d, e]

t = []
for i in permutations(list(range(5))):
    c = 0
    for j in range(4):
        c += ceil(s[i[j]] / 10) * 10
    c += s[i[4]]
    t.append(c)

print(min(t))

Submission status: Accepted

Solution code:
lis = []
ans = 0
for i in range(5):
    a = int(input())
    amari = a%10
    if a%10 == 0:
        amari = 10
    lis.append([a, 10-amari])
lis = sorted(lis, key=lambda x:x[1])
#print(lis)
for i in range(4):
    ans += lis[i][0] + lis[i][1]
    #print(ans)
ans += lis[4][0]
print(ans)

Submission status: Accepted

Solution code:
import itertools

l = [int(input()) for _ in range(5)]
order_list = list(itertools.permutations(l))

min = 10**7
for order in order_list:
    sum = 0
    for i in range(4):
        sum += order[i]
        if sum % 10 > 0:
            sum += 10 - sum % 10
    sum += order[4]

    if sum < min:
        min = sum

print(min)

Submission status: Accepted

Solution code:
def checkDigit(a):
  while(a > 10):
    a %= 10
  return a
  
a = [int(input()) for i in range(5)]
calc = []
for i in range(5):
  tmp = checkDigit(a[i])
  if tmp != 0:
    calc.append(tmp)
calc.sort()

ans = sum(a)
for i in range(1, len(calc)):
  ans += 10 - calc[i]
print(ans)

Submission status: Accepted

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

div = 0
sum = 0
l = [a, b, c, d, e]

for i in range(len(l)):
    if(l[i] % 10 != 0):
        sum += (l[i]//10+1)*10
        if((l[i]//10+1)*10 - l[i] > div):
            div = (l[i]//10+1)*10 - l[i]
    else:
        sum += l[i]
        
print(sum-div)

Submission status: Accepted

Solution code:
import itertools

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())



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

combination = list(itertools.permutations(dish))

ans = []
count = 0

for i in combination:
    time = 0
    for j in i:
        if count != 4:
            time = time + j
            if time % 10 != 0:
                while time % 10 != 0:
                    time = time + 1
            count = count+1
        elif count == 4:
            time = time + j
            count = 0
            ans.append(time)

print(min(ans))

Submission status: Accepted

Solution code:
import itertools

A = list(map(int, open(0).read().split()))
items = list(itertools.permutations(A))

ans = float('inf')

for item in items:
    t = 0
    for i in item[:-1]:
        t += (i if i%10==0 else (i//10+1)*10)
    t += item[-1]

    if t < ans:
        ans = t

print(ans)

Submission status: Accepted

Solution code:
import itertools

dish = []

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

perms = list(itertools.permutations(dish))

res = float('Inf')

for perm in perms:
    x = 0
    for i in range(len(perm)):
        x = x + perm[i]
        if i != len(perm) - 1:
            while x % 10 != 0:
                x = x + 1
    if x < res:
        res = x
        x = 0

print(res)

Submission status: Accepted

Solution code:

X = []
Y = []
for i in range(5):
    x = int(input())
    X.append(x)
    Y.append((10 - (x % 10)) % 10)

idx = Y.index(max(Y))
y = X.pop(idx)
Y.pop(idx)
print(sum(X) + sum(Y) + y)

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
xs = [A, B, C, D, E]
xs.sort(key=lambda x: 10 if x % 10 == 0 else x % 10, reverse=True)
t = 0
for x in xs[:-1]:
    t += (x + 9) // 10 * 10
t += xs[-1]
print(t)

Submission status: Accepted

Solution code:
import numpy as np
l = np.array([int(input()) for _ in range(5)])
m = ((l+9)//10)*10
n = max(m-l)
#print(l)
#print(m)
#print(n)
print(sum(m)-n)

Submission status: Accepted

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

b=[(1+(d-1)//10)*10 for d in D]
c=sum(b)

ans=10**3

for i in range(n):
    ans=min(ans,c-b[i]+D[i])
print(ans)

Submission status: Accepted

Solution code:
from itertools import permutations
Minute=[int(input()) for _ in range(5)]

ans_l=set()
for M in permutations(Minute):
    res=0
    ans=0
    for i in range(5):
        res+=M[i]
        if i==4:
            break
        if res%10!=0:
            res=-(-res//10)*10
    ans_l.add(res)

print(min(ans_l))

Submission status: Accepted

Solution code:
m = 9
l = []
r = []
for i in range(5):
  a = int(input())
  if a % 10 != 0:
    m = 10 - a % 10
    b = a + m
    l.append(b)
    r.append(m)
  else:
    l.append(a)
    r.append(0)
r.sort()
print(sum(l) - r[-1])

Submission status: Accepted

Solution code:
import itertools
l = [0,1,2,3,4]
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a,b,c,d,e]
ans =[]
time = 0
for k in itertools.permutations(l):
  time=0
  time += li[k[0]]
  for i in range(1,5):
    while time %10 !=0:
      time+=1
    time += li[k[i]]
  ans.append(time)
print(min(ans))

Submission status: Accepted

Solution code:
X = sorted([int(input()) for _ in range(5)], key=lambda x: x%10 if x%10==0 else 10-x%10)
ans = sum([((x+9)//10)*10 for x in X[:-1]])
print(ans + X[-1])

Submission status: Accepted

Solution code:
a = 0
max_dish = 0
sum_dish = 0
for _ in range(5):
    dish = int(input())
    x = dish % 10
    if x != 0:
        x = 10 - x
    a += x
    sum_dish += dish
    max_dish = max(x, max_dish)
print(sum_dish + a - max_dish)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst = [a,b,c,d,e]
last = 10
ttl = 0
for i in range(5):
    if lst[i]%10 != 0:
        ttl += (lst[i]+(10-lst[i]%10))
    if lst[i]%10 == 0:
        ttl += lst[i]
    if 0 <(lst[i]%10) <= last:
        last = lst[i]%10
print(ttl-(10-last))

Submission status: Accepted

Solution code:
import sys
from math import ceil

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    L = [INT() for _ in range(5)]

    idx = 0
    for i in range(5):
        idx = i if (L[i]-1)%10 < (L[idx]-1)%10 else idx

    for i in range(5):
        if i != idx: L[i] = ceil(L[i]/10) * 10

    print(sum(L))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
m=[]
cnt=0
for i in range(5):
    x=int(input())
    m.append(x)
m10=[i % 10 for i in m if i %10 >=1]
if m10:
    t=min(m10)
    for i in m:
        if i %10==0:
            cnt += i
        else:
            cnt += ((i//10)+1)*10
    print(cnt-10+t)
else:
    print(sum(m))

Submission status: Accepted

Solution code:
dish = [int(input()) for x in range(5)]
hitoketa = list(map(int, [str(x)[-1] for x in dish]))

last = 999
for i in hitoketa:
    if not i % 10 == 0:
        last = min(last, i)

if last != 999:
    last = dish[hitoketa.index(last)]
else:
    last = dish[0]

ans = last
skip = False

for i in dish:
    if i == last and not skip:
        skip = True
    elif i % 10 == 0:
        ans += i
    else:
        ans += (i // 10 + 1) * 10

print(ans)

Submission status: Accepted

Solution code:
cook = list(map(int, [input() for _ in range(5)]))

def hun(n):
  if n % 10 == 0:
    return n//10*10
  else:
    return (n//10 + 1) * 10

a=10
ans=0
for x in cook:
  ans += hun(x)
  if x % 10 != 0:
    a = min(a, x % 10)

print(ans - 10 + a)

Submission status: Accepted

Solution code:
nums = [int(input()) for _ in range(5)]
mods = [(10 - num % 10 if num % 10 != 0 else 0) for num in nums]
last = max(mods)
print(sum(nums) + sum(mods) - last)

Submission status: Accepted

Solution code:
lis = []
cnt = 0
for i in range(5):
    val = 0
    a = int(input())
    while a % 10 != 0:
        a += 1
        val += 1
    lis.append(a)
    if val > cnt:
        cnt = val
#print(cnt)
ans = sum(lis)
print(ans - cnt)

Submission status: Accepted

Solution code:
"""
最も時間ロスが大きい注文は最後に注文することで時間が節約できる
時間のロスは(10-(調理時間の1の位の値))で計算できる == 1の位が最小
最後の注文以外の注文時間は1の位繰り上げの値となる
最後の注文の切り上げ分を最終結果からマイナスしておく
"""

def ceil(a, b):
  return -(-a//b) * 10

A = [int(input()) for _ in range(5)]
ceiled = [ceil(a,10) for a in A]
loss = [x-y for x,y in zip(ceiled, A)]
print(sum(ceiled) - max(loss))

Submission status: Accepted

Solution code:
num = [int(input()) for _ in range(5)]
ceil = [10*(i//10) if i%10==0 else 10*(i//10+1) for i in num]
w = max(x - y for x,y in zip(ceil,num))
print(sum(ceil) - w)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    menu = [int(input()) for _ in range(5)]

    ans = 0
    min_m = 10
    for m in menu:
        ans += (m + 9) // 10 * 10
        if m % 10 > 0:
            min_m = min(min_m, m % 10)
    if min_m > 0:
        ans += min_m - 10
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=[ int(input()) for i in range(5)]
b=[(a[i]-1)%10 for i in range(5)]
m=(10-((min(b)+1)%10))%10
def f(x):
  if x%10==0:
    return x
  else:
    return x-(x%10)+10
ans=-m
for i in range(5):
  ans+=f(a[i])
print(ans)

Submission status: Accepted

Solution code:
#125 b
def age(x):
    if x%10==0:
        return x
    else:
        return x+10-x%10

r=[]
amari=[]
amari_new=[]
amari_min=10
ans=0
for i in range(5):
    d=int(input())
    amari.append(d%10)
    r.append(age(d))

for x in range(5):
    if x!=0 and amari_min>x:
        amari_min=x
ans+=sum(r)


for x in amari:
    if x!=0:
        amari_new.append(x)

if amari_new:
    amari_min=min(amari_new)
    ans-=10-amari_min

print(ans)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = []
li.append(a)
li.append(b)
li.append(c)
li.append(d)
li.append(e)

ans = []
sum_a = 0
for i in li:
  num = i % 10
  sum_a += i
  if num == 0:
    ans.append(0)
  else:
    ans.append(10-num)
num_a = sum_a + sum(ans) - max(ans)
print(str(num_a))

Submission status: Accepted

Solution code:
t=[int(input()) for _ in range(5)]
v=[10*(i//10) if i%10==0 else 10*(i//10+1) for i in t]
w=max(x-y for x,y in zip(v,t))
print(sum(v)-w)

Submission status: Accepted

Solution code:
a=[int(input()) for _ in [0]*5]
b=[-(-i//10)*10-i for i in a]
print(sum(b)+sum(a)-max(b))

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
count=0
lis=[[A,((A%10)-1)%10],[B,((B%10)-1)%10],[C,((C%10)-1)%10],[D,((D%10)-1)%10],[E,((E%10)-1)%10]]
lis.sort(key=lambda x:x[1], reverse=True)
#print(lis)

for i in range(len(lis)):
    if not(i==len(lis)-1):
        count=count+lis[i][0]+(10-(lis[i][0])%10)%10
    else:
        count=count+lis[i][0]
print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a = [int(input()) for _ in range(5)]
max_i = 9
flag_0 = 0
ans = 0
for i in range(5):
    if a[i] % 10 != 0:
        flag_0 = 1
        max_i = min(max_i,a[i]%10)
        ans += (a[i]//10)*10 + 10
    else: ans += a[i]
if flag_0:
    ans -= 10 - max_i
print(ans)

Submission status: Accepted

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

amaris = sorted([ i % 10 for i in lst if i%10 != 0])
ans = sum(lst)

for amari in amaris[1:]:
  ans += (10-amari)
  
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import itertools

a=[]
min=10
ans=0

for i in range(5):	
	a.append(float(input()))
	if (min>a[i]%10)and(a[i]%10>0):
		min=int(a[i])%10
	a[i]=a[i]/10
	a[i]=math.ceil(a[i])
	a[i]=int(a[i])*10
	ans+=a[i]

ans=ans-10+min
print(ans)

Submission status: Accepted

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

L1 = [x for x in L if x%10 == 0]
L2 = [x for x in L if x%10 != 0]
L3 = [(x%10,x//10) for x in L2]

ans = sum(L1)
if len(L3)>0:
  L3.sort(reverse = True)
  for i in range(len(L3)-1):
    ans += (L3[i][1]+1)*10
  ans += L3[-1][1]*10+L3[-1][0]
print(ans)

Submission status: Accepted

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

l.sort()

ans = 0
flag = True
for l1, l2 in l:
  if l1 == 0:
    ans += l2
  elif flag:
    ans += l2
    flag = False
  else:
    ans += ((l2//10) + 1) * 10

print(ans)

Submission status: Accepted

Solution code:
import math

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


re0 = menus[0] + m[1]+ m[2]+ m[3]+ m[4]
re1 = m[0] + menus[1]+ m[2]+ m[3]+ m[4]
re2 = m[0] + m[1]+ menus[2]+ m[3]+ m[4]
re3 = m[0] + m[1]+ m[2]+ menus[3]+ m[4]
re4 = m[0] + m[1]+ m[2]+ m[3]+ menus[4]
print(min(re0,re1,re2,re3,re4))

Submission status: Accepted

Solution code:
import numpy as np

N = []

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

f = []

for i in range(5):
    f.append([N[i]%10,i])

f.sort()
m = 0

for i in range(5):
    if f[i][0] > 0:
        m = f[i][1]
        break

ans = 0

for i in range(5):
    if i == m:
        ans += N[i]
    else:
        ans += int(10*np.ceil(N[i]/10))   
 
print(ans)

Submission status: Accepted

Solution code:
from math import ceil
menu1 = []
menu2 = []
for _ in range(5):
    m = int(input())
    if m % 10 == 0:
        menu1.append(m)
    else:
        menu2.append(m)
menu2 = sorted(menu2, key=lambda x: str(x)[-1])

ans = sum(menu1)
for i, m in enumerate(menu2):
    if i == 0:
        ans += m
        continue
    ans += ceil(m / 10) * 10
print(ans)

Submission status: Accepted

Solution code:
q = -1
r = 10
for i in range(5):
  k = int(input())
  q += (k-1)//10+1
  r = min(r-1,(k-1)%10)+1
print(q*10+r)

Submission status: Accepted

Solution code:
N=5
A=list(int(input()) for _ in range(N))

mi=9
index=0
for i in range(N):
    if A[i]%10!=0:
        if mi>A[i]%10:
            mi=A[i]%10
            index=i

ans=0    
for i in range(N):
    if i==index:
        ans+=A[i]
    else:
        ans+=(A[i]//10)*10
        if A[i]%10:
            ans+=10
print(ans)

Submission status: Accepted

Solution code:
import sys

*T, = map(int ,sys.stdin.read().split())

def main():
    res = 0
    e = 10
    for t in T:
        res += 10 * ((t + 10 - 1) // 10)
        e = min(e, (t - 1) % 10 + 1)

    res -= (10 - e)
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

Solution code:
import itertools
def ABC123B():
    T = [int(input()) for _ in range(5)]
    templist = itertools.permutations(T)
    mint = 644
    for l in templist:
        time = 0

        for t in l:
            if time % 10 !=0:
                time += 10 - time % 10
            time += t
        mint = min(mint, time)
    print(mint)


ABC123B()