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: Wrong Answer

Solution code:
min_num = 10
num = 0
count = 0
for i in range(5):
    a = int(input())
    if a % 10 == 0:
       num += a
    else:
        num += ((a//10) + 1) * 10
        min_num = min(min_num, a%10)
        count = 1

print(num+min_num-(count*10))

Submission status: Wrong Answer

Solution code:
times = [int(input()) for _ in range(5)]
times1 = []
total = 0
for t in times:
  t1 = t % 10
  times1.append(t1)
  if t1 == 0:
    total += t
  else:
    total += (t//10 + 1) * 10
total = total + min(times1) - 10
print(total)

Submission status: Wrong Answer

Solution code:
A=[]
for i in range(5):
  A.append(input())
A.sort(key=lambda x:x[-1])
ans=0
A=[int(x) for x in A]
for i in range(1,5):
  ans+=A[i]//10*10
  ans+=0 if A[i]%10==0 else 10
print(ans+A[0])

Submission status: Wrong Answer

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

ans = min(a%10, b%10, c%10, d%10, e%10) + (a+(10-a%10)) + (b+(10-b%10))+(c+(10-c%10))+(d+(10-d%10))+(e+(10-e%10)) -10

print(ans)

Submission status: Wrong Answer

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

result = 0
for each in a:
    if each % 10 != 0:
        result += each + 10 - (each % 10)
    else:
        result += each
print(result)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
s = [[a%10,a//10*10+10,a],[b%10,b//10*10+10,b],[c%10,c//10*10+10,c],[d%10,d//10*10+10,d],[e%10,e//10*10+10,e]]
s.sort()
while True:
    if s[0][0] == 0:
        s[0][1]-=10
        s.append(s.pop(0))
    else:
        break
s = np.array(s)
ans = s[0][2] + sum(s[1:,1])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a=sorted(list(map(int,[input()for i in range(5)])),key=lambda x:x%10)
while str(a[0])[-1]=='0':
  a+=[a[0]]
  del a[0]
print(sum([a[0]]+[10*(0--i//10)for i in a[1:]]))

Submission status: Time Limit Exceeded

Solution code:
i=0
s,t=0,10*i
for _ in range(5):
  s=s+int(input())
  while(s>t):
    i+=1
  s=t+10
print(s)

Submission status: Time Limit Exceeded

Solution code:
import math
a = [input().rstrip() for _ in range(5)]
a = sorted(a, key=lambda x: x[-1], reverse=True)

while True:
    m = a.pop()
    if m[-1] == '0':
        a.insert(0, m)
    else:
        break

s = sum([math.ceil(int(n) / 10) * 10 for n in a])
s += int(m)

print(s)

Submission status: Time Limit Exceeded

Solution code:
A = sorted( [input()[::-1] for i in range(5)] )
while (A[0][0] == "0"):
  tmp = A.pop(0)
  A.append(tmp)

A = [int(a[::-1]) for a in A][::-1]

def roundUp(n):
  return n if n%10==0 else n + (10-n%10)

print(sum([roundUp(A[i]) for i in range(4)]) + A[4])

Submission status: Accepted

Solution code:
a = list(int(input()) for _ in range(5))
print(sum(map(lambda x:(x+9)//10*10, a))-max(map(lambda x:(10-x%10)%10, a)))

Submission status: Accepted

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

min_rem = 10
ans = 0
for i in range(5):
    ans += (a[i] + 10 - 1) // 10 * 10
    if min_rem > a[i] % 10 > 0:
        min_rem = a[i] % 10

if min_rem != 10:
    ans -= (10 - min_rem)
print(ans)

Submission status: Accepted

Solution code:
dish=[int(input()) for i in range(5)]
dish_s=[(dish[i]+9)//10 for i in range(5)]
dish_d=[dish[i]%10 for i in range(5)]
sum=0
for i in range(5):
  sum+=dish_s[i]
m=0
for i in range(5):
  if dish_s[i]*10-dish[i]>m:
    m=dish_s[i]*10-dish[i]  
print(sum*10-m)

Submission status: Accepted

Solution code:
list_dish = [input() for i in range(0, 5)]
list_disit1 = [int(list_dish[i][-1]) for i in range(0, 5)]
marking = 0
min = 9
ans = 0
for i in range(0, 5):
    if list_disit1[i] != 0 and list_disit1[i] <= min:
        marking = i
        min = list_disit1[i]
for i in range(0, 5):
    if i == marking:
        ans += int(list_dish[i])
    else: ans += -(-int(list_dish[i]) // 10) * 10
print(ans)

Submission status: Accepted

Solution code:
import math


def main():
    t = []
    for i in range(5):
        t.append(int(input()))

    max_wait = 0
    max_wait_order = 0
    for i in range(len(t)):
        if t[i] % 10 != 0 and 10 - (t[i] % 10) >= max_wait:
            max_wait = 10 - t[i] % 10
            max_wait_order = i

    time = 0
    for i in range(len(t)):
        if i == max_wait_order:
            continue
        else:
            time += math.ceil(t[i] / 10) * 10
    time += t[max_wait_order]

    print(time)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from decimal import Decimal, ROUND_UP

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

for i in range(len(l)):
    rl.append(int(Decimal(str(l[i])).quantize(Decimal('1E1'), rounding=ROUND_UP)))

ans = []
for j in range(len(rl)):
    num = sum(rl) - rl[j] + l[j]
    ans.append(num)

print(min(ans))

Submission status: Accepted

Solution code:
def main():
    # n = int(input())
    # n, m = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]

    import math

    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    dishes = [a, b, c, d, e]
    count = 0
    mini = 10
    index = 0
    for i in range(5):
        if dishes[i] % 10 != 0 and mini > dishes[i] % 10:
            mini = dishes[i] % 10
            index = i
    for i in range(5):
        if i != index:
            count += math.ceil(dishes[i]/10) * 10
        else:
            count += dishes[i]

    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

a = [int(input()) for i in range(5)]
sub = 0
cnt = 0

for i in a:
    if i%10!=0 and sub<(10-i%10):
        sub = 10-i%10
    cnt += math.ceil(i/10)*10
print(cnt-sub)

Submission status: Accepted

Solution code:
foods = [0] * 5
sumfoods = 0
for i in range(5):
  foods[i] = int(input())
maxDiv = 0
for i, var in enumerate(foods):
  temp = 10 - (var % 10)
  if temp == 10:
    temp = 0
  foods[i] += temp
  sumfoods += foods[i]
  if maxDiv < temp:
    maxDiv = temp
print(sumfoods - maxDiv)

Submission status: Accepted

Solution code:
import math

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

num = 10
for i in [int(A[-1]), int(B[-1]), int(C[-1]), int(D[-1]), int(E[-1])]:
    if i != 0:
        num = min(num, i)

result = (math.ceil(int(A)/10) + math.ceil(int(B)/10) + math.ceil(int(C)/10) + math.ceil(int(D)/10) + math.ceil(int(E)/10)) * 10
if num != 10:
    result = result - 10 + num

print(result)

Submission status: Accepted

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

wasted_times = []
for dish in dishes:
    wasted_time = (10 - (dish % 10)) % 10
    wasted_times.append(wasted_time)

wasted_times.sort()
del wasted_times[-1]

ans = sum(dishes) + sum(wasted_times)
print(ans)

Submission status: Accepted

Solution code:
A = []
min_digit = 9
for _ in range(5):
  s = input()
  n = int(s)
  digit = int(s[-1])
  if digit > 0 and digit < min_digit:
    min_digit = digit
    A = A + [n]
  else:
    A = [n] + A
    
import math as m
A = [int(m.ceil(n/10)*10) for n in A[:-1]] + [A[-1]]
print(sum(A))

Submission status: Accepted

Solution code:
Value = [int(input()) for _ in range(5)]
amari = list()
for i in range(5):
  if(Value[i]%10 == 0):
    amari.append(10)
  else:
    amari.append(Value[i]%10)
min_amari = [i for i in range(5) if(min(amari)==amari[i])]

ans = 0
for i in range(5):
  if(i == min_amari[0]):
    ans += 0
  else:
    ans += (Value[i] + 10-amari[i])
ans += Value[min_amari[0]]
print(ans)

Submission status: Accepted

Solution code:
def main():
    # s = int(input())
    # n, k = map(int, input().split())
    # h = list(map(int, input().split()))
    # s = input()

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

    total = 0
    li = [a, b, c, d, e]
    mini = 10**10
    ans_idx = 0
    for i, s in enumerate(li):
        last_s = int(str(s)[-1])
        if mini > last_s and last_s != 0:
            mini = last_s
            ans_idx = i

    for i, s in enumerate(li):
        if i != ans_idx:
            if s % 10 != 0:
                total += s // 10 * 10 + 10
            else:
                total += s
        else:
            total += s

    print(total)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

d = [abs(d % 10 -10) for d in dishes if d % 10 != 0] # select nums which can be divided by 10
if d: d.remove(max(d)) 
print(sum(dishes) + sum(d))

Submission status: Accepted

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

m = 9 - min([(i-1) % 10 for i in l])

print(sum([((i-1)//10 + 1) * 10 for i in l]) - m)

Submission status: Accepted

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

s = list(map(lambda x: (10-x%10)%10, abcde))
print(sum(abcde)+sum(s)-max(s))

Submission status: Accepted

Solution code:
# 38
menu = []
jissai_menu = []
for i in range(5):
    menu.append(int(input()))
    if menu[i] % 10 == 0: 
        jissai_menu.append(menu[i])
    else:
        jissai_menu.append(menu[i] - menu[i] % 10 + 10)

ans = float('inf')
for i in range(5):
    tmp = 0
    for j in range(5):
        if j == i: continue
        tmp += jissai_menu[j]
    ans = min(ans, tmp + menu[i])

print(ans)

Submission status: Accepted

Solution code:
import sys
t=list(zip(*[[int(n[:-1] or 0),int(n[-1])] for n in (list(sys.stdin.read().split()))]))
print((sum(t[0])+len((u:=sorted(filter(lambda n:n>0,t[1])))[:0:-1]))*10+(u and u[0] or 0))

Submission status: Accepted

Solution code:
import sys
a = list(sys.stdin.read().split())
t = list(zip(*[[int(n[:-1] or 0), int(n[-1])] for n in a]))
print((sum(t[0]) + len((u := sorted(filter(lambda n: n > 0, t[1])))[:0:-1])) * 10 + (u and u[0] or 0))

Submission status: Accepted

Solution code:
A=[int(input()) for _ in range(5)]
print(sum(((x-1)//10+1)*10 for x in A)-max((10-x%10)%10 for x in A))

Submission status: Accepted

Solution code:
L = list(int(input()) for _ in range(5))
ans = 0
for l in L:
  if l%10 != 0:
    ans += (l-(l%10))+10
  else:
    ans += l
m = 0
for l in L:
  cnt = 0
  if (l%10) == 0:
    cnt += 1
  elif m < 10-(l%10):
    m = 10-(l%10)
if cnt == 5:
  m = 0
print(ans-m)

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    menu=[]
    np_menu=[]
    [menu.append(int(input())) for _ in range(5)]
    np_menu=np.array(menu)
    s_menu=sorted(np_menu,key=lambda x:x%10)
    time_counter=0
    last_add=0

    for time in s_menu:
        if time % 10 ==0:
            time_counter+=time
        elif last_add==0:
            last_add+=time
        else:
            tmp=10-(time%10)
            time_counter+=time+tmp
    time_counter+=last_add
    print(time_counter)

if __name__=="__main__":
    main()

Submission status: Accepted

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

l = []
if A%10 > 0:
  l.append(A%10)
if B%10 > 0:
  l.append(B%10)
if C%10 > 0:
  l.append(C%10)
if D%10 > 0:
  l.append(D%10)
if E%10 > 0:
  l.append(E%10)
  
ans = len(l)*10 + A + B + C + D + E - sum(l)
if len(l) > 0:
  ans += min(l) - 10
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
L = [(10 - A%10)%10,(10 - B%10)%10,(10 - C%10)%10,(10 - D%10)%10,(10 - E%10)%10]
L.sort()
print(A+B+C+D+E+L[0]+L[1]+L[2]+L[3])

Submission status: Accepted

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

Submission status: Accepted

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

b=[]
c=[]

for i in range(5):
  p=math.ceil(a[i]/10)*10
  b.append(p)
  c.append(list(str(a[i]-1)))

d=[]
for i in range(5):
  d.append(int(c[i][-1]))

print(sum(b)-(10-min(d)-1))

Submission status: Accepted

Solution code:
import sys
import copy
import math
import itertools
import numpy as np
l = [int(input()) for c in range(5)]
#10で割った余りが1以上で最も小さいものを探す
tmp = 0
cnt = 5
for i in range(5):
    if tmp < 10 - l[i]%10 and l[i]%10!=0:
        tmp = 10 - l[i]%10
        cnt = i
res = 0
for i in range(5):
    if cnt == i:
        res+=l[i]
    else:
        if l[i]%10==0:
            res+=l[i]
        else:
            res+=l[i]+10-l[i]%10

print(res)

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
A = [int(input()) for _ in range(5)]

def calc(p):
    t = 0
    for n, i in enumerate(p):
        t += A[i]
        if n == 4:
            break
        r = t % 10
        t += (10 - r) % 10
    return t

ans = INF
for p in permutations(range(5)):
    ans = min(calc(p), ans)
print(ans)

Submission status: Accepted

Solution code:
# ABC123
# Five Dishes
#B=A R=B G=C P=D T=E
Ryori = [input() for _ in range(5)]
O = []
t = 0
for i in Ryori:
    if int(i[-1]) == 0:
        x = Ryori.pop(Ryori.index(i))
        O.append(x)
Ryori = sorted(Ryori,key=lambda x: x[-1], reverse=True)

for i in range(len(Ryori)-1):
    for j in range(10):
        if (int(Ryori[i]) + j) % 10 == 0:
            t += int(Ryori[i]) + j
t += int(Ryori[-1])

for i in O:
    t += int(i)
print(t)

Submission status: Accepted

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

sum=0
for i in a_list:
    #print(((i+9)//10)*10)
    sum+=((i+9)//10)*10

ans_list=[]
for i in a_list:
    b=((i+9)//10)*10-i
    ans_list.append(sum-b)
    
print(min(ans_list))

Submission status: Accepted

Solution code:
S = [int(input()) for _ in range(5)]
l=[]
m=10
for i in range(5):
    if (S[i]%10)<m and S[i]%10!=0:
        m=S[i]%10
        a=S[i]
        j=i
if m==10:
    a=S[0]  
    j=0      
for i in range(5):
    if  i!=j:
        if S[i]%10!=0:
            S[i]+=10-(S[i]%10)
        l.append(S[i])
l.append(a)
print(sum(l))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

last = a
if b % 10 != 0 and (last % 10) > (b % 10):
    last = b
if c % 10 != 0 and (last % 10) > (c % 10):
    last = c
if d % 10 != 0 and (last % 10) > (d % 10):
    last = d
if e % 10 != 0 and (last % 10) > (e % 10):
    last = e

target = [a, b, c, d, e]
target.remove(last)
ans = 0
for v in target:
    ans += (((v + 10 - 1) // 10) * 10)
ans += last
print(ans)

Submission status: Accepted

Solution code:
ans=0
t=[]
tmp=10
for i in range(5):
    t.append(int(input()))
    if t[i]%10!=0 and t[i]%10<tmp:
        tmp=t[i]%10
#print(tmp)
flg=0
for i in range(5):
    if (t[i]%10!=tmp or flg==1) and t[i]%10==0:
        ans+=t[i]
    elif (t[i]%10!=tmp or flg==1) and t[i]%10!=0:
        ans+=(t[i]//10+1)*10
    elif t[i]%10==tmp and flg==0:
        ans+=t[i]
        flg=1
print(ans)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=[a,b,c,d,e]
f.sort()
x=0
for i in range(5):
  if f[i]%10==0:
    x=x+f[i]
  if f[i]%10!=0:
    x=x+(f[i]//10)*10+10
g=a-(a//10)*10
h=b-(b//10)*10
i=c-(c//10)*10
j=d-(d//10)*10
k=e-(e//10)*10
l=[g,h,i,j,k]
l.sort()
y=0
z=0
for i in range(5):
  if l[i]!=0:
    y=y+1
    z=i
    break
if y==0:
  print(x)
else:
  print(x-(10-l[z]))

Submission status: Accepted

Solution code:
last = 0
answer = 0
dishes = []
dishes.append(int(input()))

for i in range(1,5):
	dish = int(input()) 
	dishes.append(dish)
	if dish % 10 != 0 and dishes[last] % 10 >  dish % 10:
		last = i


for i in range(5):
	if i == last:
		answer += dishes[i]
	else:
		if dishes[i] % 10 == 0:
			answer += dishes[i] 
		else:
			answer += ((dishes[i]//10)+1)*10

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
lst = [a, b, c, d, e]
ans = 1 <<10
for i in itertools.permutations(lst, 5):
    cnt = 0
    for num, j in enumerate(i):
        if num == 4:
            cnt += j
            break
        if j%10 != 0:
            cnt += 10 * (j//10) + 10
        else: cnt += j
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
from math import ceil
orders = list(int(input()) for _ in range(5))
total = 0
maximum = 0

for order in orders:
    time = ceil(order / 10) * 10
    total += time
    delta = time - order
    maximum = max(maximum, delta)
print(total - maximum)

Submission status: Accepted

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

v_mod = [x%10 if x%10 != 0 else 10 for x in V]
min_mod = min(v_mod)

ans = 0
for i, v in enumerate(V):
    ans += v + (10 - v_mod[i])
ans -= (10 - min_mod)
print(ans)

Submission status: Accepted

Solution code:
# B - Five Dishes
C = [int(input()) for _ in range(5)]
C.sort(key=lambda x:-x%10)
ans = 0
for c in C[:4]:
    ans += 10*((c-1)//10+1)
ans += C[4]
print(ans)

Submission status: Accepted

Solution code:
menu=[]
menu2=[]
total=False
c=0
total2=0
for i in range(5):
    a=int(input())
    menu.append(a)
    menu2.append(a%10)
    if a%10==0:
        total2+=1
if total2==5:
    print(sum(menu))
else:
    for i in range(1,10):
        for k in range(5):
            if menu2[k]==i:
                total=True
                c=k
                break
        if total==True:
            break
    print(sum(menu)+10*(4-total2)-sum(menu2)+menu2[c])

Submission status: Accepted

Solution code:
from itertools import permutations
ls=[int(input()) for _ in range(5)]
ans = 1000000
for p in permutations(ls):
    t = 0
    for x in p[:-1]:
        t += x
        if t % 10 != 0:
            t += 10-(t%10)
    t += p[-1]
    ans = min(ans,t)
print(ans)

Submission status: Accepted

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

print(sum(jikan)-max(amari))

Submission status: Accepted

Solution code:
from itertools import permutations

def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def calc(i, h):
    return all(h[i] >= h[j] for j in range(i))


def main():
    ans = 1000
    data = [int(input()) for i in range(5)]
    for row in permutations(data, 5):
        time = 0
        for index, i in enumerate(row):
            if index == 4:
                time += i
                continue
            remain = i % 10
            if remain:
                time += i + (10-remain)
            else:
                time += i
        ans = min(ans, time)
    print(ans)



main()

Submission status: Accepted

Solution code:
a = []
for _ in range(5):
    a.append(int(input()))
c = 0
d = 0
for i in range(5):
    b = a[i] % 10
    if b != 0 and abs(10 - b) > c:
        c = abs(10 - b)
        d = i
e = a.pop(d)
f = 0
for j in a:
    g = j % 10
    if g == 0:
        f += j
    else:
        f += (j // 10 + 1) * 10
f += e
print(f)

Submission status: Accepted

Solution code:
from itertools import permutations

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
a = [a,b,c,d,e]

perms = list(permutations(a))
ans = float('inf')
for x in perms:
    cur = 0 
    x = list(x)
    for i in range(5):
        cur += x[i]
        temp = cur % 10
        if temp != 0 and i != 4:
            cur += (10 - temp)
    ans = min(ans,cur)
print(ans)

Submission status: Accepted

Solution code:
def main():
    cost_list = [int(input()) for _ in range(5)]
    amari_list = [cost % 10 for cost in cost_list]

    last_order = 0
    min_amari = 10
    for index, amari in enumerate(amari_list):
        if amari == 0:
            continue
        if amari < min_amari:
            min_amari = amari
            last_order = index

    ans = 0
    for index, cost in enumerate(cost_list):
        if index == last_order:
            ans += cost_list[index]
        else:
            if cost % 10 == 0:
                ans += cost
            else:
                cost = (cost // 10 + 1) * 10
                ans += cost

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from itertools import permutations
import math
menu=5
times=[int(input()) for i in range(menu)]
orders=list(permutations(times))
minimum=sum(math.ceil(time/10)*10 for time in times)
for order in orders:
    total=order[0]
    for i in range(1,menu):
        total+=math.ceil(order[i]/10)*10
    minimum=min(minimum,total)
print(minimum)

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
b = [9 - (i - 1) % 10 for i in a]
print(sum(a) + sum(b) - max(b))

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]
tot = 0
for i in l:
  tot+=-(-i//10)*10
  
a=max(map(lambda x: -(-x//10)*10-x, l))

print(tot-a)

Submission status: Accepted

Solution code:
A = sorted( [int(input()) for i in range(5)], key = lambda x : - x % 10)

ans = 0
for i in range(4):
  ans += A[i]
  if ans % 10 > 0:
    ans += 10 - ans % 10
print(ans + A[4])

Submission status: Accepted

Solution code:
from itertools import permutations
from math import ceil

times = list(int(input()) for _ in range(5))
orders = list(permutations(times, 5))
minimum = sum(ceil(time/10)*10 for time in times)

for order in orders:
    total = order[0]
    for i in range(1, 5):
        total += ceil(order[i]/10)*10
    minimum = min(minimum, total)
print(minimum)

Submission status: Accepted

Solution code:
from itertools import permutations
from math import ceil

times = list(int(input()) for _ in range(5))
orders = list(permutations(times, 5))
minimum = sum(ceil(time/10)*10 for time in times)

for order in orders:
    cnt = order[0]
    for i in range(1, 5):
        cnt += ceil(order[i]/10)*10
    minimum = min(minimum, cnt)
print(minimum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

num_list = [a, b, c, d, e]
factorial = list(itertools.permutations(num_list, 5))
ans_list = []
for list in factorial:
    tmp = 0
    for i in list:
        if tmp%10 == 0:
            tmp += i
        else:
            tmp += 10 - tmp%10
            tmp += i
    ans_list.append(tmp)

ans_list.sort()
ans = ans_list[0]

print(ans)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=[a,b,c,d,e]
data=[0]*5
for i in range(5):
  if f[i]%10==0:
    continue
  else:
    data[i]=10-f[i]%10
print(a+data[0]+b+data[1]+c+data[2]+d+data[3]+e+data[4]-max(data))

Submission status: Accepted

Solution code:
import math

dishes = []
rest = 10

for i in range(5):
    n = int(input())
    dishes.append(math.ceil(n / 10) * 10)
    if 0 < n % 100 % 10 < rest:
        rest = n % 100 % 10 

print(sum(dishes) - (10- rest))

Submission status: Accepted

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

mn = a[0] % 10
for i in a:
    if i % 10 == 0:
        continue
    mn = min(mn, i % 10)

for i in a:
    if i % 10 == mn:
        mn = i
        break


ans = 0
for i in a:
    if i == mn:
        ans += i
        mn = -1
        continue
    t = ((i + 9) // 10) * 10
    ans += t

print(ans)

Submission status: Accepted

Solution code:
from math import ceil
time=[int(input())for i in range(5)]
mod=[i%10 for i in time]
a=124
res=0
for i in range(len(mod)):
    if mod[i] !=0:
        a=min(a,mod[i])
if a==124:
    a=0
for i in range(5):
    if i==mod.index(a):
        res+=time[i]
    else:
        res+=ceil(time[i]/10)*10
print(res)

Submission status: Accepted

Solution code:
import itertools
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
ls = [A,B,C,D,E]
ls2 = []
for i in itertools.permutations(ls,5):
  ls2.append(list(i))
minimum = 10**5
for i in ls2:
  now = 0
  for j in range(5):
    if j == 0:
      now += i[j]
    else:
      if now % 10 == 0:
        now += i[j]
      else:
        now = 10 * (now//10+1)
        now += i[j]
  if now < minimum:
    minimum = now
print(minimum)

Submission status: Accepted

Solution code:
M = 0
ans = 0
for i in range(5):
  a = int(input())
  b = ((a + 9) // 10) * 10
  M = max(M, b-a)
  ans += b
print(ans - M)

Submission status: Accepted

Solution code:
t=[]
aa=10
for i in range(5):
    x=int(input())
    y=(x-1)%10
    aa=min(aa,y)
    for i in range(14):
        if 10*i>=x:
            t.append(10*i)
            break
print(sum(t)-10+aa+1)

Submission status: Accepted

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

diff=0
num=0
for i in l:
  if i%10==0:
    num+=i
  else:
    a=round(i+5,-1)
    num+=a
    diff=max(diff,a-i)

print(num-diff)

Submission status: Accepted

Solution code:
x = list(map(int, (input() for i in range(5))))
y = sorted(x, key= lambda x:((x+9)//10)*10-x)

s = 0
for z in y[:-1]:
  s += ((10 + z -1)//10)*10
print(s+y[-1])

Submission status: Accepted

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

last = foods.pop(foods.index(min(foods, key=lambda x: (x - 1) % 10)))
print(sum(map(lambda x: ((x + 9) // 10) * 10, foods)) + last)

Submission status: Accepted

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

res = 0
for i in times:
  res += (int(i)//10)*10+(10 if i[-1] != "0" else 0)
  
time = []
for j in times:
  time.append((int(j[-1]) if j[-1] != "0" else 10))
  
print(res - 10 + min(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]
remains = []
for t in times:
    remains.append(t%10)
last_item_i = -1
rmin = 1e8
for i in range(len(remains)):
    if remains[i] != 0 and remains[i] < rmin:
        rmin = remains[i]
        last_item_i = i
if last_item_i == -1:
    last_item_i = 0

ans = 0
for i in range(len(times)):
    if i != last_item_i:
        t = ((times[i] + 10 - 1)//10)*10
        ans += t

ans += times[last_item_i]

print(ans)

Submission status: Accepted

Solution code:
from itertools import permutations
from math import ceil

times = [int(input()) for _ in range(5)]
orders = list(permutations(times))
minimum = sum(ceil(time/10)*10 for time in times)

for order in orders:
    total = order[0]
    for i in range(1, 5):
        total += ceil(order[i]/10)*10
    minimum = min(minimum, total)
print(minimum)

Submission status: Accepted

Solution code:
x = [int(input()) for i in range(5)]
y=0
for i in x:
  if i%10==0:
    y+=i
  else:
    y+=(i+(10-(i%10)))
a=[]
for i in x:
  a.append(i%10)
if a.count(0)!=5:
  while 0 in a:
    a.remove(0)
  b=sorted(a)
  print(y-(10-b[0]))
else:
  print(y)

Submission status: Accepted

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

def f(x):
    if 1 <= x and x <= 10:
        return 10
    elif 11 <= x and x <= 20:
        return 20
    elif 21 <= x and x <= 30:
        return 30
    elif 31 <= x and x <= 40:
        return 40
    elif 41 <= x and x <= 50:
        return 50
    elif 51 <= x and x <= 60:
        return 60
    elif 61 <= x and x <= 70:
        return 70
    elif 71 <= x and x <= 80:
        return 80
    elif 81 <= x and x <= 90:
        return 90
    elif 91 <= x and x <= 100:
        return 100
    elif 101 <= x and x <= 110:
        return 110
    elif 111 <= x and x <= 120:
        return 120
    else:
        return 130
    
aa = a + f(b) + f(c) + f(d) + f(e)
bb = b + f(c) + f(d) + f(e) + f(a)
cc = c + f(d) + f(e) + f(a) + f(b)
dd = d + f(e) + f(a) + f(b) + f(c)
ee = e + f(a) + f(b) + f(c) + f(d)
print(min(aa, bb, cc, dd, ee))

Submission status: Accepted

Solution code:
a = [int(input()) for _ in range(5)]
z,ans = 123,0
for i in a:
    if i%10!=0:z = min(z,i%10)
    ans += 10*((i+10-1)//10)
print(ans+z-10 if (z!=123) or (z==0) else ans)