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())
l=[a,b,c,d,e]
s=[]
t=[]
x=0
for i in range(5):
    s.append(l[i]%10)
for i in range(5):
    if s[i]==0:
        t.append(l[i])
    else:
        t.append((l[i]//10+1)*10)
        
for i in range(1,10):
    if s.count(i)>0:
        x=10-i
        break
print(sum(t)-x)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readline_s = sys.stdin.readline
readlines = sys.stdin.buffer.readlines


def main():

    num = []
    for i in range(5):
        num.append(int(readline()))

    k = 99
    ind = -1
    for i in range(5):
        r = num[i] % 10
        if r != 0:
            if r < k:
                k = r
                ind = i

    ans = 0
    for i in range(5):
        if i == ind:
            ans += num[i]
        else:
            ans += 10 * ((num[i] - 1) // 10 + 1)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
*a, = map(int, open(0).read().split())
ans = 0
m = 10
for i in a:
    if i % 10 != 0:
        m = min(m, i % 10)
        ans += i//10*10 + 10
    else:
        ans += i//10*10
print(ans-10+m)

Submission status: Accepted

Solution code:
#

import sys
from math import ceil
input=sys.stdin.readline

def main():
    t=[int(input()) for i in range(5)]
    tp10=[t[i]%10 for i in range(5) if t[i]%10!=0]
    ans=0
    for i in range(5):
        ans+=ceil(t[i]/10)*10
    if len(tp10)>0:
      	print(ans-10+min(tp10))
    else:
      	print(ans)
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np
A = np.array(list(map(int, open(0).read().split())))

next_time = (np.array(A) + 9) // 10 * 10
 
if A[np.nonzero(A%10)].size > 0:
    print(sum(next_time) - (10 - min(A[np.nonzero(A%10)]%10)))
else:
    print(sum(next_time))

Submission status: Accepted

Solution code:
A = list(map(int, open(0).read().split()))

import numpy as np

if len([(x%10, i) for i,x in enumerate(A) if x%10!=0]) == 0:
    print(sum(A))
else:
    last_order = A[min([(x%10, i) for i,x in enumerate(A) if x%10!=0])[1]]
    print(sum(A) + sum(10 - np.array([x%10 for x in A if x%10!=0])) - (10 - min([x%10 for x in A if x%10!=0])))

Submission status: Accepted

Solution code:
def resolve():
    ans = [input() for _ in range(5)]
    an = 0
    count = []
    for i in range(5):
        if ans[i][-1]=="0":
            an += int(ans[i])
        else:
            an += int(ans[i])+10-int(ans[i][-1])
            count.append(int(ans[i][-1]))
    print(an-10+min(count) if len(count) != 0 else an)
resolve()

Submission status: Accepted

Solution code:
ans = 0
last_v = 0
for i in range(5):
    tmp = int(input())
    if tmp % 10 == 0:
        tmp_v = 0
    else:
        tmp_v = 10 - tmp % 10 
    if tmp_v> last_v:
        last_v = tmp_v
    ans += tmp + tmp_v
print(ans - last_v)

Submission status: Accepted

Solution code:
import itertools
t=[0]*5
for i in range(5): t[i]=int(input())
t=list(itertools.permutations(t))
ans=10**5
for i in t:
    a=0
    for j in i:
        if a!=0: a+=0 if a%10==0 else 10-(a%10)
        a+=j
    ans=min(ans,a)
print(ans)

Submission status: Accepted

Solution code:
A = [int(input()) for _ in range(5)]
ans = 0
temp2 = 10

for i in range(5):
    if A[i] % 10 == 0:
        ans += A[i]
    else:
        temp = (A[i]//10)*10 + 10
        ans += temp
        if temp2 > A[i] % 10:
            temp2 = A[i] % 10


temp2 = 10 - temp2
ans = ans - temp2
print(ans)

Submission status: Accepted

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

# In[17]:


abcde = []
for _ in range(5):
    abcde.append(int(input()))
print(sum(-(-x//10)*10 for x in abcde) + min(x%10 if x%10 != 0 else 10 for x in abcde ) - 10)


# In[ ]:

Submission status: Accepted

Solution code:
import itertools

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

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

min_m = 999 * 5
for abcde in itertools.permutations(l, 5):
    # print(abcde)
    end = 0
    for v in abcde:
        mod = end % 10
        if mod != 0:
            end += 10 - mod
        end += v
        # print(end)
    if end < min_m:
        min_m = end
print(min_m)

Submission status: Accepted

Solution code:
import itertools
import math

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

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

permutations = list(itertools.permutations(range(5)))

ans = float('inf')
for p in permutations:
    time = 0
    for i in range(5):
        time += menu[p[i]]
        if i != 4:
            time = math.ceil(time / 10) * 10
    ans = min(ans, time)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools


def actual(a, b, c, d, e):
    all_permutations = list(itertools.permutations([a, b, c, d, e], 5))

    order_time_list = []

    for orders in all_permutations:
        elapsed_time = 0

        for i in range(5):
            elapsed_time += orders[i]

            if i == 4:
                # 最後の注文は時間の調整不要
                continue

            fraction = elapsed_time % 10

            if fraction != 0:
                # 10で割り切れない場合は注文できないのでそれを調整する
                # ex: 57分なら +3分(⇔10 - 57%10)
                elapsed_time += 10 - fraction

        order_time_list.append(elapsed_time)

    return min(order_time_list)

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

print(actual(a, b, c, d, e))

Submission status: Accepted

Solution code:
#ABC123-B
import numpy as np
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

tmp = [a,b,c,d,e]
time = []
for i in range(5):
    if tmp[i] % 10 != 0:
        s = ((tmp[i]) // 10 + 1)*10 - tmp[i]
    else:
        s = 0
    time.append(s)
    
idx = np.argmax(np.array(time))
last = tmp.pop(idx)
#print('tmp:',tmp)
#print('idx',idx)
result = 0
for j in range(4):
    if tmp[j] % 10 != 0:
        result += (tmp[j] // 10 + 1)* 10
    else:
        result += tmp[j]
        
result += last

print(result)

Submission status: Accepted

Solution code:
flag = False
mini = 124
time = 0
for _ in range(5):
    A = int(input())
    if A%10 == 0:
        time += A
    else:
        time += A - A%10 + 10
        mini = min(A%10, mini)
        flag = True
if flag:
    time += mini - 10
print(time)

Submission status: Accepted

Solution code:
a = [ int(input()) for _ in range(5) ]
import math
#a = [123,123,123,123,123]
b = 0
total = 0
for i in a:
  x = math.ceil(i / 10) * 10
  b = max(b, x - i)
  total += x

print(total - b)

Submission status: Accepted

Solution code:
lis = []
rank1 = []
for i in range(5):
  lis.append(input())
  rank1.append( 10 if lis[-1][-1] == "0" else int(lis[-1][-1]))

min_index = rank1.index(min(rank1))
  
ans = 0
for i in range(5):
  if i == min_index:
    continue
  ans = (ans + int(lis[i]) + 9)//10*10
ans += int(lis[min_index])

print(ans)

Submission status: Accepted

Solution code:
def ip():return int(input())
ans=0
m=10
for i in range(5):
    a=ip()
    if a%10>0:
        ans+=(a//10+1)*10
    else:ans+=a
    if a%10>0:m=min(m,a%10)
print(ans-(10-m))

Submission status: Accepted

Solution code:
import math

lis = []
for _ in range(5):
    lis.append(int(input()))
    
def roundup(x):
    return int(math.ceil(x/10)) * 10
    

    
minind = 9
tmp2 = 0
for i in range(5):
    tmp = str(lis[i])
    if tmp[-1] != "0":
        minind = min(minind, int(tmp[-1]))
        if minind == int(tmp[-1]):
            tmp2 = lis[i]
   
if tmp2 == 0:
    print(sum(lis))
    exit()

lis.remove(tmp2)

for j in range(4):
    lis[j] = roundup(lis[j])
        
print(sum(lis)+tmp2)

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]
print(a+b+c+d+e+sum(L)- max(L))

Submission status: Accepted

Solution code:
a=[]
yojo=[]
sm=0
for i in range(0,5):
  x=int(input())
  if x%10==0:
    x-=10
  a.append(x//10)
  yojo.append(x%10)

yo=[10 if i==0 else i for i in yojo]
out=sum(a)*10+40+min(yo)

print(out)

Submission status: Accepted

Solution code:
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
x = math.ceil(a / 10)
x += math.ceil(b / 10)
x += math.ceil(c / 10)
x += math.ceil(d / 10)
x += math.ceil(e / 10)
rems = [r for r in [a%10, b%10, c%10, d%10, e%10] if r != 0]
if len(rems) > 0:
    ans = 10*(x-1) + min(rems)
else:
    ans = 10*x
print(ans)

Submission status: Accepted

Solution code:
arr=[int(input()) for i in range(5)]
brr=[]
result=0

for i in range(5):
    if arr[i]%10!=0:
        brr.append(arr[i]%10)
    else:
        brr.append(arr[i])
ans=brr.index(min(brr))



for i in range(5):
    if i==ans or arr[i]%10==0:
        result+=arr[i]
    else:
        result+=arr[i]+10-arr[i]%10
        
print(result)

Submission status: Accepted

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

ans = 0
r =[]
for i in range(5):
  if d[i]%10!=0:
    r.append(d[i]%10)
    ans += d[i]-(d[i]%10)+10
  else:
    ans += d[i]

if len(r) == 0:
  print(ans)
  exit()
else:
  ans -= 10-min(r)
  print(ans)

Submission status: Accepted

Solution code:
from math import *

def comTime(x):
  return ceil(x/10) * 10

def solve(_l):
  s = 0
  l =sorted(_l, key=lambda x: (10-x) % 10, reverse=True)
  s += sum(map(comTime,l[1:])) + l[0]
  return s
  
_l = [int(input()) for _ in range(5)]
print(solve(_l))

Submission status: Accepted

Solution code:
import math
from collections import deque
from collections import defaultdict

import bisect

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

time = []
minValue = 10
minIndex = -1
for i in range(5):
	x = readInt()
	time.append(x)
	if int(str(x)[-1])<minValue and int(str(x)[-1]) != 0:
		minValue = int(str(x)[-1])
		minIndex = i

ans = 0

for i in time:
	tar = i-1
	if tar<11:
		x = 10
	else:
		x = int(str(int(str(tar)[:-1])+1)+"0")
	ans+=x

tyo = 10-int(str(time[minIndex])[-1])
if tyo==10:
	tyo=0

print(ans-tyo)

Submission status: Accepted

Solution code:
def main():
    menu = [ input() for a in range(5)]
    time = 0
    for i in range(len(menu)):
        if int(menu[i]) % 10 == 0:
            time += int(menu[i])
            menu[i] = "0"
    if len(menu) > 0:
        for i in range(menu.count("0")):
            menu.remove("0")
    if len(menu) > 0:
        menu.sort(key = (lambda x: 10 - int(x[-1])))

        for i in range(len(menu) - 1):
            time += int(menu[i]) + 10 - int(menu[i][-1])
        time += int(menu[-1])
    print(time)
main()

Submission status: Accepted

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

n=b.index(min(b))
p=a.pop(n)
c=[(a[i]+10-1)//10*10 for i in range(4)]
m=sum(c)+p
print(m)

Submission status: Accepted

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

def time(n):
  t = 0
  if n % 10 == 0:
    t = 0
  else:
    t = 10 - n % 10
  return t

arr = [[a, time(a)], [b, time(b)], [c, time(c)], [d, time(d)], [e, time(e)]]
arr.sort(key=lambda x: x[1], reverse=False)
arr = list(itertools.chain.from_iterable(arr))
print(sum(arr[:-1]))

Submission status: Accepted

Solution code:
A = []
B = []
for i in range(5):
    n = int(input())
    B.append(n)
    tmp = -(-n//10)*10
    A.append(tmp)

C = []
for j in range(5):
    tmp = A[j] - B[j]
    C.append(tmp)
L = max(C)

print(sum(A)-L)

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
ans = 0
u = 0
o = 0
for i in range(5):
    ans += a[i]//10*10
    if a[i]%10 > 0:
        ans += 10
        if u==0:
            u=10
        u = min(u,a[i]%10)
        o = -10
print(ans+u+o)

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]
k = []
for i in l:
    k.append(i - ((i - 1) //10) * 10)
m = 10 - min(k)
for i in range(5):
    if l[i] % 10 != 0:
        l[i] = (l[i] // 10 + 1) * 10
print(sum(l) - m)

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
ans = 10
ch = {}
b = {}
num = 0
for i in range(5):
    b[i] = a[i]
    while True:
        a[i] = a[i]%10
        if a[i] == 0:
            a[i] = 10
        if a[i] <= 10:
            ch[i] = a[i]
            break
    ans = min(ch[i],ans)
for i in range(5):
    #print("b[",i,"]=",b[i])
    if b[i] <= 99:
        if b[i] %10 == 0:
            ans -= 10
        num += b[i] - b[i]%10
        #print("num",num)
    else:
        if b[i] %10 == 0:
            ans -= 10
        num += b[i] - (b[i] - 100)%10
print(ans + num + 40)

Submission status: Accepted

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

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

t = A + B + C + D + E + (10 - a) % 10 + (10 - b) % 10 + (10 - c) % 10 + (10 - d) % 10 + (10 - e) % 10
m = max([(10 - a) % 10, (10 - b) % 10, (10 - c) % 10, (10 - d) % 10, (10 - e) % 10])
print(t - m)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
aa = 10 * ((a + 9) // 10)
bb = 10 * ((b + 9) // 10)
cc = 10 * ((c + 9) // 10)
dd = 10 * ((d + 9) // 10)
ee = 10 * ((e + 9) // 10)
if len(set([a%10,b%10,c%10,d%10,e%10]) - {0}) > 0:
    x = min(set([a%10,b%10,c%10,d%10,e%10]) - {0})
else:
    x = 10
# print(x)
print(aa+bb+cc+dd+ee-(10-x))

Submission status: Accepted

Solution code:
import itertools

# input
menu = []
for i in range(5):
  menu.append(int(input()))
  
# main
ans = []
for v in itertools.permutations(menu):
  tmp = 0
  for i in range(5):
    tmp += v[i]
    if tmp % 10 != 0 and i != 4:
      tmp += 10 - tmp % 10
  ans.append(tmp)
  
# output
print(min(ans))

Submission status: Accepted

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

sec_time = {}
sec_time["A"] = A, A % 10 if A % 10 != 0 else 10
sec_time["B"] = B, B % 10 if B % 10 != 0 else 10
sec_time["C"] = C, C % 10 if C % 10 != 0 else 10
sec_time["D"] = D, D % 10 if D % 10 != 0 else 10
sec_time["E"] = E, E % 10 if E % 10 != 0 else 10

sorted_sec_time = sorted(sec_time.items(), key=lambda x:x[1][1], reverse=True) 

result = 0
i = 0
for time in sorted_sec_time:
    result += time[1][0]
    i += 1
    if result % 10 != 0 and i != 5:
        result += 10 - result % 10
    
print(result)

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
m=1000
for i in range(5):
    tmp = a[i]
    for j in range(5):
        if i!=j:
            if a[j]%10==0: tmp+=a[j]
            else: tmp+=(a[j]+10-a[j]%10)
    m = min(m,tmp)
print(m)

Submission status: Accepted

Solution code:
a = []
max, index, ans = 0, 0, 0
for i in range(5):
    tmp = int(input())
    a.append(tmp)
    if 10 - tmp % 10 > max and tmp % 10 != 0:
        max, index = 10 - tmp % 10, i
for i in range(5):
    if i == index or a[i] % 10 == 0:
        ans += a[i]
    else:
        ans += a[i] + 10 - a[i] % 10
print(ans)

Submission status: Accepted

Solution code:
import sys
from itertools import permutations
times = [int(sys.stdin.readline().rstrip()) for _ in range(5)]
ans = 10**10
for prm in permutations(range(5)):
    res = 0
    for i, p in enumerate(prm):
        res += times[p]
        r = times[p] % 10
        if i < 4:
            if r != 0:
                res += 10 - r
    ans = min(ans, res)
print(ans)

Submission status: Accepted

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

l = sorted([a, b, c, d, e], key=lambda x: x % 10)

ans = 0
flag = False
for i in range(len(l)):
    if l[i] % 10 == 0:
        ans += l[i]
    elif flag == False:
        ans += l[i]
        flag = True
    else:
        ans += l[i]
        ans += 10 - l[i] % 10
print(ans)

'''
ans = 10**18
for v in itertools.permutations([a, b, c, d, e], 5):
    m = 0
    for i in range(len(v)):
        m += v[i]
        if i == len(v)-1:
            break
        if v[i] % 10 != 0:
            m += 10 - v[i] % 10
    ans = min(ans, m)
print(ans)

'''
# 全ての順列を計算する、最後の値は１０の余りを加算しない。

Submission status: Accepted

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

ans = 10**18
for v in itertools.permutations([a, b, c, d, e], 5):
    m = 0
    for i in range(len(v)):
        m += v[i]
        if i == len(v)-1:
            break
        if v[i] % 10 != 0:
            m += 10 - v[i] % 10
    ans = min(ans, m)
print(ans)

Submission status: Accepted

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

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

L = []
if A != 0:
  L.append(10-A)
if B != 0:
  L.append(10-B)
if C != 0:
  L.append(10-C)
if D != 0:
  L.append(10-D)
if E != 0:
  L.append(10-E)
l = sorted(L)
s = len(l)
S = 0
for i in range(0, s-1):
  S += l[i]

total = a + b + c + d + e + S
print(total)

Submission status: Accepted

Solution code:
from math import ceil
A=[0]+[int(input()) for i in range(5)]+[0]
B=[0]+[ceil(A[i]/10)*10 for i in range(1,6)]+[0]
m=130*5
for i in range(1,6):
    m=min(m,sum(B[:i])+A[i]+sum(B[i+1:]))
print(m)

Submission status: Accepted

Solution code:
#import numpy as np
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
from itertools import permutations as perm


N = int(input())
#H1,M1,H2,M2,K= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
#S= str(input())

B = int(input())
C = int(input())
D = int(input())
E = int(input())
m=1000000
l=[N,B,C,D,E]
for v in perm(l,5):
    t=0
    #print(v)
    for i in range(5):
        t+=v[i]

        if v[i] % 10 and i!=4:
            t+=10-v[i]%10
    #print(t)

    m=min(t,m)
print(m)

Submission status: Accepted

Solution code:
import math
import itertools

ceil = math.ceil

def main():
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())
    E = int(input())
    l = [A, B, C, D, E]
    ans = float('inf')
    for p in itertools.permutations(l):
        anstmp = 0
        for i, f in enumerate(p):
            if i == 4:
                anstmp += f
            else:
                anstmp += ceil(f/10)*10
        ans = min(ans, anstmp)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
menu=5
times=[int(input()) for i in range(menu)]
times.sort()
ans = 0
for i in times:
    ans += math.ceil(i/10)*10

dif = []
for i in times:
    dif.append(math.ceil(i/10)*10 - i)

print(ans - max(dif))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

tlist = [A, B, C, D, E]
mod_list = [A % 10, B % 10, C % 10, D % 10, E % 10]
mod_list_2 = mod_list[:]
count = 0
already = 0

while 0 in mod_list_2:
  mod_list_2.pop(mod_list_2.index(0))
  
min_mod = 0
if mod_list_2:
  min_mod = min(mod_list_2)
  
if min_mod == 0:
  print(A + B + C + D + E)
else:
  for i in tlist:
    if (i % 10 == min_mod) and already == 0:
      already = i
    else:
      count += int(math.ceil(i / 10) * 10)
  else:
    count += already
    print(count)

Submission status: Accepted

Solution code:
import itertools
import math

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

tlist = [A, B, C, D, E]
l = itertools.permutations(tlist, 5)

t = []
count = 0

for i in l:
  count = 0
  for j in range(5):
    if j != 4 :
      count += int(math.ceil(i[j] / 10) * 10)
    else:
      count += i[j]
  t.append(count)
  
print(min(t))

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
def time(x):
    return (x+9)//10*10
def last(x):
    return time(x)-x
sum_tim=time(a)+time(b)+time(c)+time(d)+time(e)
ans=sum_tim-max(last(a),last(b),last(c),last(d),last(e))
print(ans)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
menu=[a,b,c,d,e]
time=0
for i in ["1","2","3","4","5","6","7","8","9","0"]:
    if i in [str(a)[-1],str(b)[-1],str(c)[-1],str(d)[-1],str(e)[-1]]:
        mi=[str(a)[-1],str(b)[-1],str(c)[-1],str(d)[-1],str(e)[-1]].index(i)
        break
minu=menu[mi]
for i in range(len(menu)):
    if i!=mi:
        time+=menu[i]
        while time%10!=0:
            time+=1
time+=minu
print(time)

Submission status: Accepted

Solution code:
import numpy as np
argList = np.array([int(input()) for _ in range(5)])

#調理後次の注文までの残り時間
nokori = 10 - argList % 10
nokori[nokori==10] = 0

#調理後に一番時間が余るメニューを最後に作る
lastMenu = np.argmax(nokori)

jikan = 0
for i in range(5):
    #最後に作るメニューは　作る時間だけ加算
    if( i == lastMenu):
        jikan += argList[i]
    #それ以外は作る時間＋待機時間加算
    else:
        jikan += (argList[i] +nokori[i])
print (jikan)

Submission status: Accepted

Solution code:
m = [  int(input()) for _ in range(5) ]
m_min = sorted(m, key=lambda x: (x%10))
idx = 0
for i,x in enumerate(m_min):
    if x%10 != 0:
        idx = i
        break
order = [  i if i % 10 == 0 else (int(i/10) + 1) * 10 for i in m_min]
print(sum(order)+m_min[idx]-order[idx])

Submission status: Accepted

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

mi = 10
sm = 0
min_r = 10
for i in range(5):
	d = A[i] // 10
	r = A[i] % 10
	if r == 0:
		sm += (d)*10
	else:
		sm += (d+1)*10

	if r != 0 and min(mi,r) < mi:
		mi = min(mi,r)
		idx = i
		min_r = r
		min_d = d
	#print(min_r,min_d,i,sm)


print(sm - (10-min_r))

Submission status: Accepted

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


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

first_digit = []
for i in range(len(abcde)):
    if abcde[i] % 10 == 0:
        first_digit.append(10)
    else:
        first_digit.append(abcde[i] % 10)


ans = sum([((i-1)//10+1)*10 for i in abcde])

ans = ans-10+min(first_digit)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
x=[int(input()) for _ in range(5)]
w=[0]*5
for i in range(5):
    if x[i]%10==0:
        j=10
    else:
        j=x[i]%10
    w[i]=10-j
w.sort()
ans=sum(x)+sum(w[:4])
print(ans)

Submission status: Accepted

Solution code:
l=[input() for _ in range(5)]
i=0
m=9
for s in l:
    s=int(s[-1])
    if s==0:
        i+=1
        continue
    m=min(m,s)
a=0
for s in l:
    a+=(int(s)+9)//10*10
print(a if i==len(l) else a-10+m)

Submission status: Accepted

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

cost = []
### 0 より大きい1分台の数を求めて、それを最後に注文する
min_minute = 10
for c in [A, B, C, D, E]:
    t = int(c // 10) * 10
    if c % 10 != 0:
        t += 10
        min_minute = min(c % 10, min_minute)
    cost += [t]
print(sum(cost) - 10 + min_minute)

Submission status: Accepted

Solution code:
a,b=5,10
for i in range(5):
    i=int(input())
    a+=(i-1)//10
    if 0<i%10<b:
        b=i%10
print(a*10-(10-b))

Submission status: Accepted

Solution code:
a,b=0,10
for i in range(5):
    i=int(input())
    a+=(i-1)//10+1
    if 0<i%10<b:
        b=i%10
print(a*10-(10-b))

Submission status: Accepted

Solution code:
summ = 0
check = 10
for i in range(5):
    i = int(input())
    summ += (i - 1) // 10 + 1
    if 0 < i % 10 < check:
        check = i % 10
print(summ * 10 - (10 - check))

Submission status: Accepted

Solution code:
import math
fp = 10
ans = 0
for i in range(5):
    a = int(input())
    ans+= math.ceil(a/10)*10
    if a%10!=0:
        fp =  min(fp, a%10)
print(ans+fp -10 if fp!=10 else ans )

Submission status: Accepted

Solution code:
mino=10
ans=0
for i in range(5):
  x=int(input())
  if x%10==0:
    ans+=x
  else:
    ans+=x+10-x%10
    if mino > x%10:
      mino = x%10
ans=ans-(10-mino)
print(ans)

Submission status: Accepted

Solution code:
def last_num(a):
    while a//10!=0:
        a=a%10
    return a

def marume(a):
    b=a
    while a//10!=0:
        a=a%10
    if a!=0:
        b=b-a+10
    return b

A=[int(input())for _ in range(5)]
last_order=9
order_num=0
ans=0
for i in range(5):
    if 0 < last_num(A[i]) < last_order:
        last_order=last_num(A[i])
        order_num=i
for j in range(5):
    if j !=order_num:
        ans+=marume(A[j])
    else:
        ans+=A[j]
print(ans)

Submission status: Accepted

Solution code:
from math import ceil
t = 0
maxv = 0
for i in range(5):
	n = int(input())
	t += 10 * ceil(n / 10)
	x = n % 10
	if x != 0:
		maxv = max(maxv, 10 - x)
print(t - maxv)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import permutations


cook_times = [int(input()) for _ in range(5)]
ans = float('inf')
for ts in permutations(cook_times):
    total = 0
    for t in ts[:-1]:
        if t % 10 == 0:
            total += t
        else:
            total += (t + 9) // 10 * 10
    ans = min(ans, total + ts[-1])
print(ans)

Submission status: Accepted

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

sum_ae = 0
g = 9
cnt = 0  
for i in ae:
    if i % 10 != 0:
        g = min(g, i % 10)
        sum_ae += (i//10 + 1) * 10
        cnt += 1
    else:
        sum_ae += i
if cnt != 0:
    print(sum_ae - (10-g))
else:
    print(sum_ae)