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())
A=[a,b,c,d,e]
B=[]
C=[]
for i in range(5):
    if A[i]%10==0:
        B.append(10)
        C.append(A[i])
        
    else:
        B.append(A[i]%10)
        C.append((A[i]//10+1)*10)
j=B.index(min(B))
print(sum(C)-C[j]+A[j])

Submission status: Accepted

Solution code:
# coding:utf-8
# 調理時間の入力
cooking_time = [int(input()) for i in range(5)]
# 注文が10の倍数の時間にならないとできないので、料理ができてから注文可能になるまでの時間を出す
# 料理ができてから注文可能時間が早く来る順にする
cooking_time = sorted(cooking_time, key=lambda x: (x-1)%10, reverse=True)
#print(cooking_time)
ans = 0

for i , cooking_time in enumerate(cooking_time):
    # 1品目から4品目まで
    if i < 4:
        if cooking_time%10 != 0:
            #調理時間と注文待ち時間が加算される
            ans += cooking_time + (10-cooking_time%10)
        else:
            ans += cooking_time
    # 5品目
    else:
        ans += cooking_time

print(ans)

Submission status: Accepted

Solution code:
n=[0]*5
x=10
flag=0
sum=0
for i in range(5):
  n[i]=int(input())
  if n[i]%10!=0 and n[i]%10<x:
    x=n[i]%10
    flag=i
for i in range(5):
  if i!=flag and n[i]%10!=0:
    sum+=(n[i]+(10-n[i]%10))
  else:
    sum+=n[i]
print(sum)

Submission status: Accepted

Solution code:
a=[int(input()) for i in range (5)]
m=[]
s=0
for j in range(5):
    x=a[j]%10
    if x!=0:
        s+=a[j]+10-x
    else:
        s+=a[j]
for k in range(5):
    y=a[k]%10
    b=s
    if y!=0:
        n=10-y
        b=b-n
        m.append(b)
    else:
        m.append(b)
print(min(m))

Submission status: Accepted

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

ls = [A,B,C,D,E]
m = 10**10

for l in range(0,5):
    c = 0
    for j in range(0,5):
        if l == j:
            c+=ls[j]
        else:
            x = ls[j]
            while x%10 != 0:
                x+=1
            c+=x
    m = min(m,c)
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
dish = [0]*5
inv = [0]*5

for i in range(5):
  dish[i] = int(input())
  inv[i] = (10-dish[i]%10)%10
  
cost = sum(dish) + sum(inv) - max(inv)
print(cost)

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
b = list(map(lambda x:(x+9)//10*10, a))
print(min([sum(b)-b[i]+a[i] for i in range(5)]))

Submission status: Accepted

Solution code:
import itertools
A = []
for i in range(5):
  a = int(input())
  A.append(a)
  
Comb = list(itertools.permutations(A))
min_time = float('inf')
for i in range(len(Comb)):
  tmp = list(Comb[i])
  tmp_time = 0
  for j in range(5):
    if(j != 4):
     if(tmp[j]%10 == 0): tmp_time += tmp[j]
     else: tmp_time += 10*(tmp[j]//10 + 1)
    if(j == 4):
     tmp_time += tmp[j]
  min_time = min(min_time,tmp_time)
print(min_time)

Submission status: Accepted

Solution code:
x = 0
t = 0
for n in range(5):
    o = int(input())
    if o % 10 == 0:
        k = 0
    else:
        k = 10 - o % 10
    t += o + k
    x = max(x, k)
print(t - x)

Submission status: Accepted

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

aMod = [0, 0, 0, 0, 0]
for i in range(0,5):
    aMod[i] = a[i] % 10
    if aMod[i] == 0:
        aMod[i] = 10
    a[i] = a[i] + (10 - aMod[i])

aModMin = min(aMod)
print(sum(a) + aModMin - 10)

Submission status: Accepted

Solution code:
A = [int(input()) for i in range(5)]
B = [(int(a/10) + 1) * 10 if a % 10 != 0 else a for a in A]
C = [b-a for a, b in zip(A,B)]
print(sum(B) - max(C))

Submission status: Accepted

Solution code:
import math
dish = [int(input()) for _ in range(5)]
sm = 9
smin = 0
for cnt, item in enumerate(dish):
  r = item % 10
  if 1 <= r <= 9:
    if sm > r:
      sm = r
      smin = cnt
ans = 0    
for cnt, item in enumerate(dish):
  if cnt == smin:
    ans += item
  else:
    r = item % 10
    if 1 <= r <= 9:
      ans += item + 10 - r
    else:
      ans += item
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
A=[int(input()) for i in range(5)]
B=[]
for i in range(5):
    if int(str(A[i])[-1])!=0 and len(str(A[i]))>2:
        B.append(int(str(A[i])[:-2]+str(int(str(A[i])[-2])+1)+'0'))
    elif int(str(A[i])[-1])!=0 and len(str(A[i]))==2:
        B.append(int(str(int(str(A[i])[0])+1)+'0'))
    elif int(str(A[i])[-1])!=0 and len(str(A[i]))==1:
        B.append(10)
    else:
        B.append(int(A[i]))
a=np.array(A)
b=np.array(B)
np.array(B)-np.array(A)
tmp=np.sort(b-a)
print(sum(tmp)+sum(a)-tmp[-1])

Submission status: Accepted

Solution code:
from math import ceil
a = [int(input()) for _ in range(5)]
b = [ceil(i / 10) * 10 for i in a]
c = [sum([a[i]] + [b[j] for j in range(5) if i != j]) for i in range(5)]
print(min(c))

Submission status: Accepted

Solution code:
A = [int(input()) for i in range(5)]
amari = A[0] % 10
index = 0

for i in range(1, 5):
    if 0 < A[i] % 10 < amari:
        amari = A[i] % 10
        index = i

for i in range(5):
    if i == index:
        continue
    for j in range(10):
        if A[i] % 10:
            A[i] += 1
        else:
            break

print(sum(A))

Submission status: Accepted

Solution code:
from math import ceil
a = [int(input()) for _ in range(5)]
b = [ceil(i / 10) * 10 for i in a]
print(min([sum([a[i]] + [b[j] for j in range(5) if i != j]) for i in range(5)]))

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
li=[a,b,c,d,e]
p=[]
q=[]
for i in range(5):
  p.append(((li[i]-1)//10+1)*10)
  q.append(((li[i]//10+1)*10-li[i])%10)
print(sum(p)-max(q))

Submission status: Accepted

Solution code:
import itertools
import math

def culc(o):
  time = o[0]
  for i in o[1:]:
    time = math.ceil(time / 10) * 10
    time += i
  return time

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

p = list(itertools.permutations(d))
time = [culc(i) for i in p]

print(min(time))

Submission status: Accepted

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

a1=a%10
b1=b%10
c1=c%10
d1=d%10
e1=e%10

if a1 != 0:
    a1=10-a1
if b1 != 0:
    b1=10-b1
if c1 != 0:
    c1=10-c1
if d1 != 0:
    d1=10-d1
if e1 != 0:
    e1=10-e1

x={'a1':a1,'b1':b1,'c1':c1,'d1':d1, 'e1':e1}

max=max(x,key=x.get)

if max == 'a1':
    print(b+b1+c+c1+d+d1+e+e1+a)
elif max == 'b1':
    print(a+a1+c+c1+d+d1+e+e1+b)
elif max == 'c1':
    print(a+a1+b+b1+d+d1+e+e1+c)
elif max == 'd1':
    print(a+a1+b+b1+c+c1+e+e1+d)
else:
    print(a+a1+b+b1+c+c1+d+d1+e)

Submission status: Accepted

Solution code:
#入力
A=(input())
B=(input())
C=(input())
D=(input())
E=(input())

dishs=[A,B,C,D,E]
time=[]
time1=[]
for henkan in dishs:
    time.append(int(henkan))
    time1.append(int(henkan[-1]))

#計算
def shori(n):
    if n==0 :
        k=0
    else:
        k=10-n
    return k
time1a=list(map(shori,time1))
last=max(time1a)
totaltime=sum(time)+sum(time1a)-last

print(totaltime)

Submission status: Accepted

Solution code:
import itertools
args = []
for _ in range(5):
    tmp = int(input())
    args.append(tmp)
best = 643
for perm in itertools.permutations(args):
    remainder = 0
    cook = 0
    for i, t in enumerate(perm):
        cook += t
        if i == 4:
            break
        while(cook % 10 != 0):
            cook += 1

    cook += remainder
    if cook < best:
        best = cook
print(best)

Submission status: Accepted

Solution code:
x = [int(input()) for i in range(5)]
time = sum([(i // 10)*10 for i in x])
res = [i % 10 for i in x if i % 10 != 0]
if len(res) > 0:
    time += (len(res) - 1)*10 + min(res)
print(time)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
# 2019/04/06

from numpy import array, argmax, ones

InRange = 5

# 入力受け取り
a_e = array([int(input()) for i in range(InRange)])

# 1桁目が0以外で最小
a_e10 = 10 - a_e % 10
a_e10[a_e10 == 10] = 0

sum_index = ones(InRange, dtype=bool)
sum_index[argmax(a_e10)] = False

sum_time = a_e.sum() + a_e10[sum_index].sum()

print(sum_time)

Submission status: Accepted

Solution code:
a = 0
l = []
for _ in range(5):
  x = int(input())
  a += x
  l += [(200-x)%10]
print(a+sum(l)-max(l))

Submission status: Accepted

Solution code:
import sys, os

if __name__=='__main__':
    if 'local' in os.environ :
        sys.stdin = open('./input.txt', 'r')
    
    ans = 0
    min_mod = 10
    for i in range(5):
        x = int(input())
        ans += x//10 * 10 + (0 if x%10 == 0 else 10);
        if x%10 != 0:
            min_mod = min(min_mod, x%10);
        
    
    if min_mod == 10:
        print(ans)
    else:
        print(ans - 10 + min_mod)

Submission status: Accepted

Solution code:
import math
def main():
    num       = [int(input()) for _ in range(5)]
    rand_up   = [math.ceil(i / 10) * 10 for i in num]
    diff      = [rand_up[i] - num[i] for i in range(5)]
    max_index = diff.index(max(diff))
    print(sum([num[i] if i == max_index else rand_up[i] for i in range(5)]))

main()

Submission status: Accepted

Solution code:
a_e = [int(input()) for i in range(5)]
# 1の位を0にする
next_time_ae = [(x + 9)//10 * 10 for x in a_e]
# next_time_ae = [ x - x % 10 + 10 if x % 10 != 0 else x for x in a_e]
diff = [(b - a) for a, b in zip(a_e, next_time_ae)]

print(sum(next_time_ae)-max(diff))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc123/tasks/abc123_b
# https://upura.hatenablog.com/entry/2019/04/07/011914

# 1の位が1番小さいものを最後に頼む（0を除く）

A_E = [input() for _ in range(5)]

# 1の位だけ抜き出して整数に
unit_place_lst = [int(x[-1]) for x in A_E]
min_except0 = 10
min_index = 0
for i, n in enumerate(unit_place_lst):
    if 0 < n < min_except0:
        min_except0 = n
        min_index = i

ans = 0
for i, x in enumerate(A_E):
    if i == min_index:
        ans += int(x)
    # elif (int(x) % 10) == 0:
    #    ans += int(x)
    # else:
    #    ans += int(x) - (int(x) % 10) + 10
    else:
        ans += (int(x) + 9)//10 * 10

print(ans)

Submission status: Accepted

Solution code:
def solve(t):
    n = len(t)
    p = [t[i] % 10 for i in range(n)]
    q = [(10 - p[i]) % 10 for i in range(n)]
    return sum(t) + sum(q) - max(q)
t = [int(input()) for i in range(5)]
print(solve(t))

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

dishes=[I() for i in range(0,5)]
rounded = []
for i in dishes:
    if i%10 != 0:
        i += 10 - i % 10
    rounded.append(i)
result=10**10
for i in range(len(dishes)):
    # order i in the end
    result = min(result, sum([r for ridx, r in enumerate(rounded) if ridx != i]) + dishes[i])
    
print(result)

Submission status: Accepted

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

m = 0
res = 0
for x in a:
    if x % 10 != 0:
        t = 10 - x%10
    else:
        t = 0
    res += x + t

    m = max(m, t)

print(res - m)

Submission status: Accepted

Solution code:
l=[int(input()) for i in range(5)]
m=[c%10 for c in l if c%10>0]

def f(c):
    if c%10>0:
        return c+10-c%10
    else:
        return c

t=[f(c) for c in l]

ans=sum(t)
if len(m)>0:
  ans-=10-min(m)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
p={} #調理時間
r={} #注文-次の注文までの時間
for i in range(5):
    p[i] = int(input())
    r[i] = int((p[i] + 9) /10) * 10
    #print(r[i])

"""
for i in range(5):
    print(p[i],end=' ')
print('')

for i in range(5):
    print(r[i],end=' ')
print('')
"""
lastnum = 0
for i in range(1,5):
    if r[lastnum] - p[lastnum] < r[i] - p[i]:
        lastnum = i

#print(lastnum)

time = 0
for i in range(5):
    if i != lastnum:
        time += r[i]
    else:
        time += p[i]

print(time)

Submission status: Accepted

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

r = [c % 10 for c in cuicine if c % 10 != 0]

r = sorted(r)

# print(r)

rmin = 0

if r != []:
  rmin = r.pop(0)

ans = sum(cuicine)

for i in r:
  ans += 10 - i

print(ans)

Submission status: Accepted

Solution code:
from itertools import permutations
a = [int(input()) for _ in range(5)]
ans = float('inf')
for last,*others in permutations(a):
    time = last
    for o in others:
        time += (o+9)//10*10
    ans = min(ans, time)
print(ans)

Submission status: Accepted

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

ans = float('inf')
for last in range(5):
    time = a[last]
    for other in range(5):
        if other==last:
            continue
        time += (a[other]+9)//10*10
    ans = min(ans, time)
print(ans)

Submission status: Accepted

Solution code:
menu = [int(input()) for i in range(5)]
mod = []
for i in menu:
    mod.append(i % 10)
last_index = 0
for i in range(5):
    if mod[last_index] > mod[i] and mod[i] >= 1:
        last_index = i
res = 0
for i, v in enumerate(menu):
    if i == last_index:
        continue
    res += v
    while res % 10 != 0:
        res += 1

res += menu[last_index]
print(res)

Submission status: Accepted

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

m = 0#1の位が0以外で一番小さいもの(10との差が一番大きいもの)
sum_a = 0#10倍数にしたものの合計
for x in a:
    if x%10 != 0:
        t = 10 - x%10#10倍数との差
    else:
        t = 0
    sum_a += x+t
    m = max(m, t)

print(sum_a - m)

Submission status: Accepted

Solution code:
import numpy as np
import math

a = []
for i in range(5):
	a.append(int(raw_input()))
b = np.array(a)
c = b % 10
c[c==0]=10
min_id = np.argmin(c)

for i in range(5):
	if i != min_id:
		b[i] = 10 * math.ceil(b[i] / 10.0)
print np.sum(b)

Submission status: Accepted

Solution code:
inputs = [int(input()) for i in range(5)]
summ = 0
k = 10
for i in inputs:
    if i % 10 == 0:
        summ = summ + i
    else:
        s, m = divmod(i, 10)
        summ = summ + (s + 1) * 10
        if m < k:
            k = m

summ = summ -((10-k)%10)
print(summ)

Submission status: Accepted

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

now_time = [a, b, c, d, e]
next_time = []

for i in now_time:
    if i % 10 == 0:
        next_time.append(i)
    else:
        while i % 10 != 0:
            i += 1
        next_time.append(i)

combined = sorted([x - y for (x, y) in zip(next_time, now_time)])

best_time = sum(next_time) - max(combined)
print(best_time)

Submission status: Accepted

Solution code:
import itertools

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

x = float('inf')
for vals in itertools.permutations((a, b, c, d, e)):
    y = 0
    for val in vals[:-1]:
        y += val
        while y % 10 != 0:
            y += 1
    y += vals[-1]
    x = min(x, y)

print(x)

Submission status: Accepted

Solution code:
import itertools

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

def calc(foods):
    t = 0
    for f in foods:
        if t % 10 == 0:
            t += f
        else:
            t += 10-t%10 + f
    return t

def solve(f):
    ans = 2**32
    for it in itertools.permutations(f):
        ans = min(ans, calc(it))
    return ans

print(solve(foods))

Submission status: Accepted

Solution code:
import math

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

ABCDE = [a, b, c, d, e]
ABCDE_next = [int(math.ceil(abcde/10)*10) for abcde in ABCDE]

ans = 99999999
for i in range(len(ABCDE)):
    time = sum(ABCDE_next) - ABCDE_next[i] + ABCDE[i]
    ans = min(ans, time)
    
print(ans)

Submission status: Accepted

Solution code:
import itertools,math
A = [int(input()) for i in range(5)]
res = 10**10
for i in itertools.permutations(A):
	time = 0
	for j in i:
		time = math.ceil(time/10)*10+j
	res = min(res,time)
print(res)

Submission status: Accepted

Solution code:
import sys

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

time = 0
count = 0

for i,item in enumerate(lines):
	if item%10 == 0:
		time += item
		lines[i] = 0
		count += 1
		#print(item)

for i in reversed(range(9)):
	#print("#",i)
	for j,item in enumerate(lines):
		if item%10 == i+1:
			time += item
			lines[j] = 0
			count += 1
			if count != 5:
				time += (10 - (i+1))
			#print(item,time)

print(time)

Submission status: Accepted

Solution code:
from math import ceil
A = [input() for i in range(5)]
A = sorted(A,key = lambda x:x[-1])
A = [int(a) for a in A]
time = 0
for a in A:
	time += ceil(a/10)*10
for a in A:
	if a%10 != 0:
		time -= 10-(a%10)
		break
print(time)

Submission status: Accepted

Solution code:
import itertools

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

final_time = float('inf')
for v in itertools.permutations(don):
  time = 0
  for j in v:
    while(time % 10 != 0):
      time += 1
    time += j
  final_time = min(final_time, time)
print(final_time)

Submission status: Accepted

Solution code:
time = [int(input()) for i in range(5)]
fixedtime = []
bit = 10
arg = None

for i in range(len(time)):
    if time[i]%10 < bit and time[i]%10 != 0:
        bit = time[i]%10
        arg = i

for i in range(len(time)):
    if i == arg or time[i]%10 == 0:
        fixedtime.append(time[i])
    else:
        fixedtime.append(time[i]+10-time[i]%10)

print(sum(fixedtime))

Submission status: Accepted

Solution code:
dish = [0]*5
t = [0]*5
for i in range(5):
    dish[i] = int(input())
    t[i] = (10-(dish[i]%10))%10
m_t = max(t)
print(sum(dish)+sum(t)-m_t)

Submission status: Accepted

Solution code:
"全探索で行うパターン(最後に頼む料理によって合計の時間が変わる)"

original_time = [int(input()) for _ in range(5)]  # 元の時間
next_time = [(i+9)//10 * 10 for i in original_time]  # 次の注文を行えるまでに必要な時間

order_time = []
for i in range(len(original_time)):
    sum = 0
    for j in range(len(original_time)):
        if i == j:
            sum += original_time[j]
        else:
            sum += next_time[j]
    order_time.append(sum)

print(min(order_time))

Submission status: Accepted

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

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

list2 = [a%10,b%10,c%10,d%10,e%10]  

for i in range(5):
    if list2[i] == 0:
        list2[i] += 10


for i in (range(4)):
        for j in range(4,i,-1):
            if list2[j] > list2[j-1]:
                list2[j],list2[j-1] = list2[j-1],list2[j]
                list1[j], list1[j-1] = list1[j-1], list1[j]

s = 0
for i in range(4):
    if int(list1[i])%10 != 0:
        s += int(list1[i])-int(list1[i])%10+10
    else:
        s += int(list1[i])

s += int(list1[4])

print(s)

Submission status: Accepted

Solution code:
import sys
def fceil(b):
    return   int( b / 10) + 1  if b % 10 else b // 10
aD=[int(_) for _ in sys.stdin.readlines()]
aDM =sorted(set(_%10 for _ in aD))
aD10=[ fceil(_) * 10 for _ in aD]
iM = aDM[0]
if iM == 0:
    if 1 < len(aDM):
        iM = aDM[1]
iD = 10 - iM
if iM == 0:
    iD = 0
print(sum(aD10) - iD)

Submission status: Accepted

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

min_index = -1
min_num = 9
for i, a in enumerate(a_list):
    last = int(str(a)[-1])
    if last == 0:
        continue
    if last <= min_num:
        min_num = last
        min_index = i

if min_index == -1:
    print(sum(a_list))
    exit()

ans = 0
for i, a in enumerate(a_list):
    last = int(str(a)[-1])
    if i == min_index:
        ans += a
    elif last == 0:
        ans += a
    else:
        ans += a
        ans += 10 - last
print(ans)

Submission status: Accepted

Solution code:
count = 0
l = []
for i in range(5):
    A = input()
    if int(A[-1]) != 0:
        l.append(int(A[-1]))
        A = round(int(A)+5,-1)
    count = count + int(A)
print(count+(-10 + min(l) if l else 0 ))

Submission status: Accepted

Solution code:
# coding: utf-8
import math


def main():
    li = sorted([int(input()) for _ in range(5)],
                key=lambda i: i % 10 if i % 10 > 0 else 10,
                reverse=True)
    s = 0
    for i in li[:-1]:
        s += math.ceil(i/10) * 10
    print(s + li[-1])


main()

Submission status: Accepted

Solution code:
import math
foods = [int(input()) for _ in range(5)]
def hoge(value):
    return 9 if value % 10 == 0 else value % 10

last = min([(i, f) for i, f in enumerate(foods)], key=lambda i: hoge(i[1]))
time = 0
for food in foods[:last[0]] + foods[last[0]+1:]:
    time += math.ceil(food / 10) * 10
print(time+last[1])

Submission status: Accepted

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

list_time_reminders = []


for i in list_menu:
	reminder_i = 10 - (i % 10)
	if reminder_i == 10:
		reminder_i = 0
	
	list_time_reminders.append(reminder_i)

max_reminder = max(list_time_reminders)

list_time_reminders.remove(max_reminder)

total_cooking_time = 0

for i in list_menu:
	total_cooking_time += i

for i in list_time_reminders:
	total_cooking_time += i


print(total_cooking_time)

Submission status: Accepted

Solution code:
import itertools

a=[int(input()) for j in range(5)]
#print(a)

x=list(itertools.permutations(a))
#print(x)

def cal(b,c):
  if b <= c:
    return c
  else:
    c+=10
    return cal(b,c)
  
ans=100000000  
for i in range(len(x)):
  time1=cal(x[i][0],0)
  time2=cal(time1+x[i][1],0)
  time3=cal(time2+x[i][2],0)
  time4=cal(time3+x[i][3],0)
  time5=time4+x[i][4]

  if time5 < ans:
    ans=time5
    
print(ans)

Submission status: Accepted

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

import sys
import copy

input = sys.stdin.readline

# ---------------------------------------------------------

from itertools import permutations

A = [int(input().rstrip()) for _ in range(5)]

ans = 1000000000000000000

for B in list(permutations(A)):
    sum = 0
    for i in range(5):
        sum += B[i]
        if (i < 4):
            sum += (10 - sum % 10) % 10
    ans = min(ans, sum)

print(ans)

Submission status: Accepted

Solution code:
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)
def zeros2(n, m): return [zeros(m) for i in range(n)] # obsoleted zeros((n, m))で代替

INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def prob():
    d = Debug()
    d.off()
    N = 5
    dish = zeros(N)
    for i in range(N):
        dish[i] = int(input())
    d.dmp((dish),'dish')
    minDigit1 = 10
    idx = N
    time = 0
    for i in range(N):
        if dish[i] % 10 > 0 and minDigit1 > dish[i] % 10:
            idx = i
            minDigit1 = dish[i] % 10
        time += (dish[i]+9)//10*10
        d.dmp((time),'time')
    d.dmp((time),'time')
    d.dmp((idx),'idx')
    if idx < N:
        time -= (dish[idx]+9)//10*10
        time += dish[idx]
    return time
    

ans = prob()
print(ans)

Submission status: Accepted

Solution code:
import math

t = []
k = 0
r = 10
for i in range(5):
    v = int(input())
    tmp = v % 10
    if tmp != 0 and tmp < r:
        r = tmp
        k = i
    t.append(v)

tt = 0
for i in range(5):
    if i == k or t[i] % 10 == 0:
        tt = tt+t[i]
    else:
        tt = tt + 10 * math.ceil(t[i]/10)

print(tt)

Submission status: Accepted

Solution code:
l = [int(input()) for i in range(5)]
s = sum(list(map(lambda x: (x + 9) // 10 * 10, l)))
s -= max(list(map(lambda x: ((x + 9) // 10 * 10) - x, l)))
print(s)

Submission status: Accepted

Solution code:
A = []
B = []
for i in range(5):
    x = int(input())
    if x % 10 == 0:
        a = x
    else:
        a = (x // 10 + 1) * 10
    A.append(a)
    
    b = a - x
    B.append(b)
    
print(sum(A) - max(B))

Submission status: Accepted

Solution code:
N = 5
time = [int(input()) for _ in range(N)]
order_time = list()
sabun = list()

for i in range(N):
    if time[i] % 10 == 0:
        order_time.append(time[i])
    else:
        order_time.append(time[i] - time[i] % 10 + 10)
    sabun.append(order_time[i] - time[i])

print(sum(order_time) - max(sabun))

Submission status: Accepted

Solution code:
# import sys

dishTime = []

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

# minVal = sys.maxsize # int型最大値
minVal = dishTime[0]
minIdx = 0

for i in range(len(dishTime)):
  if dishTime[i] % 10 != 0 and minVal > (dishTime[i] % 10): # 一の位の最小値を求める
    minVal = dishTime[i] % 10
    minIdx = i # 添え字を記憶


ans = 0
for i in range(len(dishTime)):
  if i == minIdx:
    ans += dishTime[i]
    continue
  
  if dishTime[i] % 10 == 0:
    ans += dishTime[i]
  else:
    ans += (int(dishTime[i] / 10) + 1) * 10

print(ans)

Submission status: Accepted

Solution code:
a=sorted([int(input()) for i in range(5)],key=lambda x:(x-1)%10)
for i in range(1,5):
    a[i]=int((a[i]+9)/10)*10
print(sum(a))

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dish = [a,b,c,d,e]
ans = 0
maxtime = []
remain = []
for i in dish:
    maxtime.append((i+9) // 10 * 10)
for i in range(5):
    remain.append(maxtime[i] - dish[i])
ans = sum(maxtime) - max(remain)
print(ans)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
dish = [a,b,c,d,e]
ans = 0
maxtime = []
remain = []
for i in dish:
    maxtime.append((i+9) // 10 * 10)
for i in range(5):
    remain.append(maxtime[i] - dish[i])
ans = sum(maxtime) - max(remain)
print(ans)

Submission status: Accepted

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


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

def nokori(az, sitei):
	tmp = []
	flag = 0
	for a in az:
		if a == sitei and flag == 0 :
			flag = 1
		else:
			tmp.append(a)
	return tmp

def calcOrder(order):
	time = 0
	for o in order:
		if time % 10 != 0:
			time += 10 - time % 10
		time += o
	return time

time = 0
mintime = 1000
res = ''

for fst in orders:
	
	az = nokori(orders, fst)
	for sec in az:
		ax = nokori(az, sec)
		for thd in ax:
			aw = nokori(ax, thd)
			for fth in aw:
				af = nokori(aw, fth)
				for fif in af:
					time = calcOrder([fst,sec,thd,fth,fif])
					if time < mintime:
						mintime = time
						res = str([fst,sec,thd,fth,fif])

print(mintime)

Submission status: Accepted

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

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


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


def last_order(nums):
    cnt = 130
    num = 0

    for i in nums:
        if i % 10 != 0:
            if cnt > int(str(i)[-1]):
                cnt = int(str(i)[-1])
                num = i

    return num


def move_up(num):
    if num % 10 != 0:
        return  num + (10 - (num % 10))
    else:
        return num

last = last_order(orders)
if last:
    orders.remove(last)

total_time = 0

for i in orders:
    total_time = total_time + move_up(i)

print(total_time + last)

Submission status: Accepted

Solution code:
array1 = [int(input()) for i in range(5)]
array2 = [i for i in array1 if i % 10 == 0]
array3 = [i for i in array1 if i % 10 != 0]
array4 = [i % 10 for i in array3]
sum1 = 0
sum2 = sum(array2)
if (len(array3) != 0):
  idx = array4.index(min(array4))
  for k, i in enumerate(array3):
    if (k == idx):
      sum1 += i
    else:
      sum1 += i + (10 - i % 10)
print(sum1 + sum2)

Submission status: Accepted

Solution code:
from sys import stdin

def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()

A = [0] * 5
for i in range(5): A[i] = ri()
 
tot = 0
ma = 0
for i in range(len(A)):
    tot += (A[i] + 9) // 10 * 10
    if A[i] % 10 > 0 : ma = max(ma, 10 - A[i] % 10)

tot -= ma
print(tot)