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=[0]*5
a[0]=int(input())
a[1]=int(input())
a[2]=int(input())
a[3]=int(input())
a[4]=int(input())
time=0
ama=0
  
for i in range(5):
  tmp=10-a[i]%10
  if tmp==10:
    tmp=0
  a[i]+=tmp
  if ama<tmp:
    ama=tmp
    
print(sum(a)-ama)

Submission status: Accepted

Solution code:
a=int(input())
t=-a//10*-10
f=(a-1)%10
for i in range(4):
    a=int(input())
    t+=-a//10*-10
    f=min(f,(a-1)%10)
print(t-9+f)

Submission status: Accepted

Solution code:
import itertools

time = []
best_time = 10**9
for i in range(5): time.append(int(input()))

def next_time(t):
    if t%10 == 0: return t
    else: return (t//10+1)*10

for v in itertools.permutations(time):
    total_time = 0
    for i in range(5):
        if i == 4: total_time += v[i]
        else: total_time += next_time(v[i])
    best_time = min(best_time, total_time)
    
print(best_time)

Submission status: Accepted

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

tmp = 0
for i in range(5):
    if a[i] % 10 != 0:
        tmp = i if a[tmp] % 10 > a[i] % 10 else tmp

ans = 0
for i in range(5): 
    if i == tmp:
        continue
    else:
        if a[i] % 10 == 0:
            ans += a[i]
        else:
            ans += (a[i] // 10 + 1) * 10
            
print(ans + a[tmp])

Submission status: Accepted

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

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

arr = [i_i() for _ in range(5)]
arr.sort(key=lambda a: a%10)

flag = True
ans = 0
for x in arr:
    if flag and x % 10 >= 1:
        ans += x
        flag = False
    else:
        if x % 10 != 0:
            ans += (x + 10) // 10 * 10
        else:
            ans += x // 10 * 10

print(ans)

Submission status: Accepted

Solution code:
A = []
B = []
C = []
for i in range(5):
    A.append(int(input()))
    if A[i]%10 == 0:
        B.append(A[i])
    else:
        B.append((A[i]-A[i]%10)+10)
    C.append(B[i]-A[i])
sb = sum(B)
ans = sb
for i in range(5):
    ans = min(ans,sb-C[i])
print(ans)

Submission status: Accepted

Solution code:
*H,=map(int,open(0));print(sum(10*(0--i//10)for i in H)-9+min((j-1)%10 for j in H))

Submission status: Accepted

Solution code:
dishes = [int(input()) for _ in range(5)]
S = [((10 - dishes[i] % 10) % 10) * 5 + i for i in range(5)]
S.sort()
M = 0
for i in range(4):
  M += -int((-dishes[S[i]%5])//10)*10
M += dishes[S[4]%5]
print(M)

Submission status: Accepted

Solution code:
min=0
N=[]
for i in range(5):
    n=int(input())
    N.append([n,(n-1)%10])
N.sort(key=lambda x:x[1])
time=0
for i in range(4):
    time+=(-N[i+1][0]//10)*-10
print(time+N[0][0])

Submission status: Accepted

Solution code:
import math
ary1 = [int(input()) for x in range(5)]
x1 = sum(10*math.ceil(x/10) for x in ary1)
x2 = max([10-(y % 10) if y % 10 !=0 else 0 for y in ary1 ])
ans = x1 - x2
print(ans)

Submission status: Accepted

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

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

ans=0

for i in range(5):
    
    ans+=(foods[i]//10)*10
    foods[i]=foods[i]%10
    
while 0 in foods:
    foods.remove(0)
foods.sort()

if foods!=[]:
    ans+=(foods[0]+(len(foods)-1)*10)
print(ans)

Submission status: Accepted

Solution code:
a=[0]*5
b=[0]*5
ans=0
for i in range(5):
  a[i]=int(input())
  b[i]=a[i]%10
  if (b[i]==0):
    b[i]=10
  
here=b.index(min(b))
for i in range(5):
  if (i==here):
    ans+=a[i]
  else:
    if (b[i]==10):
      ans+=a[i]
    else:
      ans+=((a[i]//10)+1)*10
      
print(ans)

Submission status: Accepted

Solution code:
a=[]
for i in range(5):
    a.append(int(input()))
b=[]
for i in range(5):
    for j in range(25):
        if a[i]<=j*10:
            b.append(j*10-a[i])
            break
    
b=sorted(b,reverse=True)
print(sum(a)+(sum(b)-b[0]))

Submission status: Accepted

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

wait = []
for i in menu:
    w = i
    n = max(len(str(i)),2)
    while w % 10 != 0:
        w += 1
    wait.append([i,(w-i)%(10**(n-1))])
wait.sort(key=lambda x: x[1])
time = 0
for i in range(len(wait)):
    time += wait[i][0]
    if time % 10 != 0 and i != len(wait)-1:
        time += wait[i][1]
print(time)

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline
from math import ceil,floor

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
A = [int(input()) for _ in range(5)]

total = 0
rem = 10
for a in A:
    total += ceil(a/10)*10
    rem = min(rem, (a-1)%10+1)

print(total-10+rem)

Submission status: Accepted

Solution code:
mx = 0
s = 0
for _ in range(5):
  ai = int(input())
  if ai%10 == 0:
    s += ai
  else:
    s += 10*(ai//10)+10
    if 10-ai%10 > mx:
      mx = 10-ai%10
print(s-mx)

Submission status: Accepted

Solution code:
a = [list(map(int, input().split())) for _ in range(5)]
mod = 9
ans = 0
c = 0
 
for i in range(5):
    modi = (a[i][0]%10)
    if modi != 0:
        mod = min(mod, modi)
    else:
        c += 1
    ref = (0 - -a[i][0]//10)*10
    ans += ref
if c != 5:
    mod = 10 - mod
    ans = ans - mod
print(ans)

Submission status: Accepted

Solution code:

import math

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

max_a_idx = 0
max_dif = 0
for i in range(5):
    if a[i]%10!=0:
        x = 10-(a[i]%10)
        if x > max_dif:
            max_dif=x
            max_a_idx=i


#print("------------")
time = 0
for i in range(5):
    if i!=max_a_idx:
        if a[i]%10!=0:
            time += (a[i]+(10-a[i]%10))
        else:
            time += a[i]
        #print(str(a[i])+" "+str(time))

time += a[max_a_idx]
print(time)

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
l = []
mod = []
for i in range(5):
    num = ii()
    l.append((num+9)//10*10)
    if num%10 == 0:
        mod.append(10)
    else:
        mod.append(num%10)
a = 10-min(mod)
print(sum(l)-a)

Submission status: Accepted

Solution code:
from itertools import permutations
a = list(permutations(range(5)))
time = [int(input()) for _ in range(5)]
ans = 10000
for l in a:
  t = 0
  for i in range(5):
    t += time[l[i]] + (10 - t % 10)*(t % 10 != 0)
  ans = min(ans,t)
print(ans)

Submission status: Accepted

Solution code:
s = 0
itv = 0
for i in range(5):
  meal = int(input())
  if meal%10:
    itv = max(itv, 10 - meal%10)
    s += 10 * (meal//10 + 1)
  else:
    s += meal
print(s - itv)

Submission status: Accepted

Solution code:
import math
l=[int(input()) for i in range(5)]
li=[math.ceil(n/10)*10 for n in l]
s=sum(li)
ans=10000
for i in range(4):
    ss=s-li[i]+l[i]
    ans=min(ss,ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"

rows = [int(input()) for _ in range(5)]

lis = []
for num in rows:
    if num%10 == 0:
        lis.append(num)
    else:
        num = (num//10 + 1)*10
        lis.append(num)

snum = sum(lis)
ans = snum
for i in range(5):
    var = snum - lis[i] + rows[i]
    ans = min(ans,var)

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

Solution code:
import itertools

a = input()
b = input()
c = input()
d = input()
e = input()
l = map(int, [a, b, c, d, e])
ans = 1001001001
for i in itertools.permutations(l):
    *f, g = i
    h = 0
    for j in f:
        h += j
        while h%10 != 0: h += 1
    h += g
    ans = min(ans, h)
print(ans)

Submission status: Accepted

Solution code:
import math

l = [int(input()) for _ in range(5)]
q = []
for i in l:
    if 10 - (i % 10) != 10:
        q.append(10 - (i % 10))
    else:
        q.append(0)
total = 0
for i in l:
    total += math.ceil(i / 10) * 10
print(total - max(q))

Submission status: Accepted

Solution code:
ans_list = []
z_count = 0
for i in range(5):
    b = int(input())
    c = b%10
    ans_list.append((b,c))
    if c == 0:
        z_count += 1
ans_list.sort(key = lambda x:x[1], reverse = True)
count = 0
ans = 0
for i in range(5-z_count):
    if ans_list[i][1] is not 0:
        ans += (ans_list[i][0] -ans_list[i][1] + 10)
    else:
        ans += ans_list[i][0]
if ans_list[5-z_count-1][1] is not 0:
    ans -=(10-ans_list[5-z_count-1][1])
for i in range(z_count):
    ans += ans_list[5-z_count+ i][0]

print(ans)

Submission status: Accepted

Solution code:
import math
A,B,C=[],[],[]
for i in range(5):
  a=int(input())
  A.append(a)
  B.append(a%100%10)
B=[9 if i==0 else i for i in B]
C=list(map(lambda x:math.ceil(x/10)*10,A))
print(sum(C)-C[B.index(min(B))]+A[B.index(min(B))])

Submission status: Accepted

Solution code:
import numpy as np
import sys
readline = sys.stdin.readline
read = sys.stdin.read

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

A = np.array([a, b, c, d, e])
B = A
A = (A // 10) * 10 + 10
mx = 0
s = np.sum(A)
for i in range(5):
	if A[i] - B[i] == 10:
		s -= 10
	else:
		if mx < A[i] - B[i]:
			mx = A[i] - B[i]
print(s - mx)

Submission status: Accepted

Solution code:
f=[]
t=[]
r=[0]
for i in range(5):
    f.append(int(input()))
for i in range(5):
    if f[i]%10!=0:
        r.append(10-f[i]%10)
        t.append((f[i]//10+1)*10)
    else:
        t.append(f[i])
print(sum(t)-max(r))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a = I()
b = I()
c = I()
d = I()
e = I()
lst = [a,b,c,d,e]
ans = inf
for i in permutations(range(5)):
    time = 0
    for j in i:
        if time % 10 == 0:
            time += lst[j]
        else:
            time += (10 - time % 10)
            time += lst[j]
    ans = min(ans,time)
print(ans)

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  TIME = 0
  ORDER = [int(input()) for _ in range(5)]
  for i in range(5):
    for j in range(i,5):
      if (ORDER[i] % 10 != 0 and ORDER[j] % 10 != 0) and ORDER[i] % 10 >= ORDER[j] % 10:
        tmp = ORDER[i]
        ORDER[i] = ORDER[j]
        ORDER[j] = tmp
      
  ORDER = ORDER[::-1]
  #print(ORDER)
  for i in range(5):
    #ORDER = int(input())
    TIME += ORDER[i]
    if i == 4:
      break
    if TIME % 10 != 0:
      TIME += 10 - (TIME%10)
    #print(TIME)
  print(TIME)
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import itertools


min_time = 1000000
D = [int(input()) for _ in range(5)]
for p in itertools.permutations(D):
    time = 0
    for i in range(5):
        d = p[i]
        if i < 4:
            for _ in range(9):
                if d%10 == 0:
                    break
                d += 1
        time += d
    min_time = min(min_time, time)
print(min_time)

Submission status: Accepted

Solution code:

from itertools import permutations

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

minT = 10000

for a in permutations(l,5):
    t = 0
    for dish in a:
        if t%10 != 0:
            t += 10 - t%10
        t += dish
    minT = min(minT,t)
print(minT)

Submission status: Accepted

Solution code:

from itertools import permutations

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

minT = 10000

for a in permutations(l,5):
    t = 0
    for dish in a:
        if t%10 != 0:
            t += 10 - t%10
        t += dish
    minT = min(minT,t)
print(minT)


"""
from itertools import permutations

dishes = [int(input()) for _ in range(5)]

minT = 10000
for sample in permutations(dishes, 5):
    t = 0
    for dish in sample:
        if t%10 != 0:
            t += 10 - t%10
        t += dish
    minT = min(minT, t)
print(minT)
"""

Submission status: Accepted

Solution code:

from itertools import permutations

dishes = [int(input()) for _ in range(5)]

minT = 10000
for sample in permutations(dishes, 5):
    t = 0
    for dish in sample:
        if t%10 != 0:
            t += 10 - t%10
        t += dish
    minT = min(minT, t)
print(minT)

Submission status: Accepted

Solution code:
import math
List = [int(input()) for i in range(5)]
last = list(map(lambda x: x % 10, List))

lastnum = 0

last = sorted(last)
for i in range(5):
  if last[i] == 0:
    lastnum = 10
  else :
    lastnum = last[i]
    break

tensum =  list(map(lambda x: (math.ceil(x / 10))*10, List))

print(sum(tensum) - 10 + lastnum)

Submission status: Accepted

Solution code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    a =[]

    max =0
    for i in range(5):
        b = int(input())
        a.append(b)

        c = 10 - b%10
        if c <10 and max < c:
            max =c

    sum =0

    for i in a:
        c = 10 - i % 10
        if max ==c:
            sum += i
            max = 11
        else:
            if c ==10:
                sum +=i
            else:
                sum+= i +c

    print(sum)

Submission status: Accepted

Solution code:
def main():
  data = []

  for _ in range(5):
    data.append(int(input()))

  # 10の倍数から1番離れてる数がどれか
  min = 99
  margin = []
  for d in data:
    tmp = d % 10
    if tmp != 0:
      margin.append(10 - tmp)
    if tmp != 0 and min > tmp:
      min = tmp

  # 0対策
  if min == 99:
    print(sum(data) + sum(margin))
    return

  # print(data)
  # print(margin)
  # print(min)
  print(sum(data) + sum(margin) - (10-min))

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
A=[int(input()) for _ in range(5)]
ans=0
B=[a%10 for a in A]
m=1001001001
s=0
for i in range(5):
  if B[i]!=0 and m>B[i]:
    s=i
    m=B[i]
U=A[s]
del A[s]
for i in range(4):
  if A[i]%10==0:
    ans+=A[i]
  else:
    ans+=((A[i]//10)+1)*10
print(ans+U)

Submission status: Accepted

Solution code:
n = [int(input()) for i in range(5)]
m = 10
x = n[0]
#1の位が最も小さいものはそのまま足す・残りは1の位を切り上げて足す

for i in n:
  if int(str(i)[-1]) < m and int(str(i)[-1]) > 0:
    m = int(str(i)[-1])
    x = i



n.remove(x)
    
for i in range(len(n)):
  if n[i]%10 != 0:
    n[i] = n[i] + 10 - int(str(n[i])[-1])

print(sum(n) + x)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

order = [int(input()) for _ in range(5)]

extra_list = []

tmp = 11
for i in range(5):
    extra = order[i] % 10
    if extra != 0:
        if extra < tmp:
            tmp = extra
            extra_list.append(i)


ans = 0
for i in range(5):
    if extra_list and i == extra_list[-1]:
        continue
    if order[i] % 10 == 0:
        ans += order[i]
    else:
        ans += 10 * (order[i] // 10 + 1)
if extra_list:
    print(ans + order[extra_list[-1]])
else:
    print(ans)

Submission status: Accepted

Solution code:
import math

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

an = a%10
bn = b%10
cn = c%10
dn = d%10
en = e%10

ans = 0

if an==0:
    an = 10
if bn==0:
    bn = 10
if cn==0:
    cn = 10
if dn==0:
    dn = 10
if en==0:
    en = 10

arfa = min([an,bn,cn,dn,en])

for x in [a,b,c,d,e]:
    ans += math.ceil(x/10)*10
print(ans - 10 + arfa)

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    a=INT()
    b=INT()
    c=INT()
    d=INT()
    e=INT()
    ct=0
    alls=[a,b,c,d,e]
    for i in alls:
        if i%10!=0:
            ct+=(i//10+1)*10
        else:
            ct+=i
    f=max((10-a%10)%10,(10-b%10)%10,(10-c%10)%10,(10-d%10)%10,(10-e%10)%10,)
    ct=ct-f
        
    print(ct)
if __name__ == '__main__':
    do()

Submission status: Accepted

Solution code:
import copy
a = [list(map(int, input().split())) for _ in range(5)]
b = copy.deepcopy(a) #二次元配列だと単純なコピーでは参照が残る。
a2 = []
diff = 0
total = 0

for i in range(5):
    b[i][0] = (0 - (-b[i][0]//10)*10)
    a2.append(b[i][0])

total = sum(a2)

for i in range(5):
    diff1 = b[i][0] - a[i][0]
    diff = max(diff, diff1)

ans = total - diff
print(ans)

Submission status: Accepted

Solution code:
a = [list(map(int, input().split())) for _ in range(5)]
mod = 9
ans = 0
c = 0

for i in range(5):
    modi = (a[i][0]%10)
    if modi != 0:
        mod = min(mod, modi)
    else:
        c += 1
    ref = (0 - -a[i][0]//10)*10
    ans += ref
if c != 5:
    mod = 10 - mod
    ans = ans - mod
print(ans)

Submission status: Accepted

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

res = []
diff = []
for i in range(5):
    tmp = 0
    if(x[i] % 10 == 0):
        tmp = (x[i] // 10) * 10
    else:
        tmp = (x[i] // 10 + 1) * 10
    res.append(tmp)
    diff.append(tmp - x[i])

print(sum(res) - max(diff))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import permutations
def main():
    t = [int(input()) for _ in range(5)]
    tp = permutations(t)
    ans = 1000*5
    for p in tp:
        total = 0
        for i,pi in enumerate(p):
            if i == 4:
                total += pi
                break
            a,b = divmod(pi,10)
            if b == 0:
                total += a*10
            else:
                total += a*10+10
        ans = min(ans,total)
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

dishes=[int(input()) for _ in range(5)]
#print(dishes)

remain=[val%10 for val in dishes if val%10!=0]
up=[math.ceil(val/10)*10 for val in dishes]
#print(remain)
#print(up)
if not remain:
    print(sum(up))
else:
    print(sum(up)-10+min(remain))

Submission status: Accepted

Solution code:
import sys

dishes = map(int, sys.stdin.read().split())
ans = 0
d = 0
for dish in dishes:
    wait_time = 10 - dish % 10
    if wait_time == 10:
        wait_time = 0
    if wait_time > d:
        ans += dish + d
        d = wait_time
    else:
        ans += dish + wait_time
print(ans)

Submission status: Accepted

Solution code:
#conding utf-8
A=[int(input()) for i in range(5)]
B=[0 for i in range(5)]
C=[0 for i in range(5)]

tmp=10
m=0
for i in range(5):
  if A[i]%10 !=0:
    if A[i]%10<tmp:
      m=i
      tmp=A[i]%10

for i in range(5):
  if A[i]%10 !=0:
    if i != m:
      B[i]=int(A[i]/10)*10+10
    else:
      B[i]=A[i]
  else:
    B[i]=A[i]

print(sum(B))

Submission status: Accepted

Solution code:
#FiveDishes.py

time = [int(input())for _ in range(5)]
ans = 10000000


def up(n):
	s = list(str(n))
	if s[-1]!="0":
		s[-1] = "0"
		n = int("".join(s))
		n += 10
	return n

time_up = [int(up(time[i])) for i in range(5)]


for i in range(5):
	#print(time_up)
	t = sum(time_up)- time_up[i]
	#print(time[i])
	temp = time[i]+t
	ans = min(ans,temp)
	#print(ans)
print(ans)

Submission status: Accepted

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

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,menu))
minimum = sum(math.ceil(time/10)*10 for time in times)
for order in orders:
  total = 0
  for i in range(menu-1):
    total += math.ceil(order[i]/10)*10
  total += order[4]
  minimum = min(minimum,total)
  
print(minimum)

Submission status: Accepted

Solution code:
li = [int(input()) for _ in range(5)]
def fun(a):
    if a % 10 == 0:
        return a
    else:
        return a + 10 - a % 10
su = sum(list(map(fun, li)))
last = li[0]
for l in li:
    if l % 10 != 0 and last % 10 > l % 10:
        last = l
print(su - fun(last) + last)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = [input() for _ in range(5)]
T = []
U = []
for i in range(5):
  T.append(S[i])
  if int(T[i][-1]) == 0:
    U.append(9)
  else:
    U.append(int(T[i][-1]))
del T[U.index(min(U))]
import math
a = 0
for i in range(4):
  a += math.ceil(int(T[i])*0.1)*10
a += int(S[U.index(min(U))])
print(a)

Submission status: Accepted

Solution code:
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

x = [int(input()) for _ in range(5)]
ans, x = sum(i for i in x if i % 10 == 0), [i for i in x if i % 10 > 0]
if len(x) == 0:
    print(ans)
else:
    x.sort(key=lambda i: i % 10, reverse=True)
    print(ans + sum((i // 10 + 1) * 10 for i in x[:-1]) + x[-1])

Submission status: Accepted

Solution code:
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  #a,b = list(map(int,input().split()))
  #a = [list(map(int,input().split())) for i in range(6)]
  a = [int(input()) for i in range(5)]
  ans = 0
  hi = 9 
  count = 0
  
  for i in range(5):
    if a[i] % 10 >= 1:
      ans += a[i] + (10-a[i]%10)
      hi = min(hi,a[i]%10) 
    else:
      ans += a[i]
      count += 1

  if count == 5:
    print(ans)
  else:
    print(ans-10+hi)
  
      
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
A, B, C, D, E  = [int(input()) for i in range(5)]
S = [A, B, C, D, E]
s = []

for i in S:
    s.append(i%10)

for i in range(5):
    if s[i]==0:
        s[i]=9

for i in range(5):
    if s[i]==min(s):
        tmp = S[i]
        S.pop(i)
        break

sum = 0
for i in S:
    if i%10!=0:
        sum += (i//10+1)*10
    elif i%10==0:
        sum += i

print(sum+tmp)

Submission status: Accepted

Solution code:
A=[]
for i in range(5):
    B=int(input())
    A.append(B)
min=1000
count=0
for j in range(5):
    if A[j]%10!=0 and A[j]%10<min:
        min=A[j]%10
        index=j
    if A[j]%10==0:
        count+=1
if count==5:
    index=0
time=0
for k in range(len(A)):
    if k!=index:
        time=time+A[k]
        if A[k]%10!=0:
            time=time+(10-A[k]%10)
    else:
        time=time+A[k]
print(time)

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]
l1 = [a%10,b%10,c%10,d%10,e%10]
l2 = [(a//10)*10+10,(b//10)*10+10,(c//10)*10+10,(d//10)*10+10,(e//10)*10+10]
for i in range(len(l)):
    if l[i]%10 == 0:
        l1[i] = 10
        l2[i] -= 10
print((sum(l2)-(10-(min(l1)))))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a,b,c,d,e]
index = -1
def rou(n):
    if(n%10==0): return n
    return n+10-n%10

mi=(li[0]-1)%10
for i in range(5):
    if((li[i]-1)%10 <= mi):
        mi=(li[i]-1)%10
        index = i

ans = 0
for i in range(5):
    if(index == i):
        ans += li[i]
    else:
        ans += rou(li[i])
print(ans)

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
time = 10
for i in range(5):
         if (a[i] + 9) % 10 < time:
                  time = (a[i] + 9) % 10
                  mindish = i
ans = 0
for i in range(5):
         ans += ((a[i] + 9 ) //10)*10
ans = ans - (((a[mindish] + 9 )//10 ) *10)+ a[mindish]
print(ans)

Submission status: Accepted

Solution code:
L=[]
M=[]
for i in range(5):
	X=int(input())
	L.append(X)
	M.append(X%10)
tmp=float("inf")
for i in range(5):
	if M[i]!=0:
		tmp=min(tmp,M[i])
cmd=0
ans=0
for i in range(5):
	if M[i]==tmp and cmd==0:
		ans+=L[i]
		cmd+=1
	else:
		if L[i]%10==0:
			ans+=L[i]
		else:
			ans+=((L[i]//10)+1)*10
print(ans)

Submission status: Accepted

Solution code:
l = []
num = []

for i in range(5):
    menu = int(input())
    if menu%10 != 0:
        num.append(menu%10)
        menu = (menu//10+1)*10
    l.append(menu)

ans = sum(l)

if num:
    ans -= 10-min(num)

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
sho_ls = []
amari_ls = []
a_ls = []
for _ in range(5):
    a = int(input())
    a_ls.append(a)
    sho, amari = divmod(a,10)
    sho_ls.append(sho)
    amari_ls.append(amari)

amari_ls_not0 = []
for i in range(5):
    if amari_ls[i] != 0:
        amari_ls_not0.append(amari_ls[i])

if amari_ls != [0,0,0,0,0]:
    amari_min_not0 = min(amari_ls_not0)
    arg_min = amari_ls.index(amari_min_not0)
else:
    arg_min = 0
ans = 0
for i in range(5):
    if i != arg_min:
        if amari_ls[i] != 0:
            plus = a_ls[i] + 10 - amari_ls[i]
            ans += plus
            
        else:
            plus = a_ls[i]
            ans += plus
plus = a_ls[arg_min]
ans += plus
print(ans)

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]
ans = 1000

def return_time(t):
    time = t//10 * 10
    mod = t%10
    if mod != 0:
        time += 10
    return time

for v in itertools.permutations(dish, 5):
    t1, t2, t3, t4, t5 = v[0], v[1], v[2], v[3], v[4]
    total = 0
    for t in [t1, t2, t3, t4]:
        total += return_time(t)
    total += t5
    ans = min(ans, total)

print(ans)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
ansa=0
ansb=0
ansc=0
ansd=0
anse=0

if str(a)[-1]=="0":
  ansa=0
else:
  ansa=str(a)[-1]
  ansa=10-int(ansa)
  
if str(b)[-1]=="0":
  ansb=0
else:
  ansb=str(b)[-1]
  ansb=10-int(ansb)
  
if str(c)[-1]=="0":
  ansc=0
else:
  ansc=str(c)[-1]
  ansc=10-int(ansc)
  
if str(d)[-1]=="0":
  ansd=0
else:
  ansd=str(d)[-1]
  ansd=10-int(ansd)
  
if str(e)[-1]=="0":
  anse=0
else:
  anse=str(e)[-1]
  anse=10-int(anse)
  
sum1=ansa,ansb,ansc,ansd,anse
ans1=sum(sum1)-max(sum1)

ans2=a+b+c+d+e
print(int(ans1)+int(ans2))

Submission status: Accepted

Solution code:
a=[]
r=[]
for i in range(5):
    n=int(input())
    q=-(-n//10)*10
    a.append(q)
    if n%10!=0:
        r.append(n%10)
    else:
        r.append(10)
print(sum(a)-10+min(r))

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
mi = 10
count = 0
for i in range(5):
    if a[i] % 10 != 0:
        if mi > (a[i]%10):
            mi = a[i] % 10
        a[i] += (10 - a[i]% 10)
    count+=a[i]
print(count-10+mi)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem B - Five Dishes

import itertools
import math

# input process
cost_list = []
for i in range(5):
    cost_list.append(int(input()))

# initialization
min_ans = 1000

# count process
perm_list = list(itertools.permutations(cost_list))
for p in perm_list:
    p = list(p)
    # cost calc
    tmp = 0
    for i in range(len(p)):
        if i==4:
            tmp += p[i]
            break
        tmp += p[i]
        tmp = math.ceil((tmp/10))*10

    min_ans = min(min_ans, tmp)

# output process
print(min_ans)