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:
min_d = None
total = 0
for _ in range(5):
    i = int(input())
    total += i // 10 * 10
    d = i % 10
    if d != 0:
        if min_d is None:
            min_d = d
        else:
            min_d = min(min_d, d)
        total += 10
if min_d is None:
    print(total)
else:
    print(total - (10 - min_d))

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]
result=0

mx=-1

for dd in dish:
    for i in range(0,10):
        if (dd+i) % 10 == 0:
            tmp=i
            break
    if tmp > mx:
        mx = tmp
        buf=dd

dish.remove(buf)

for dd in dish:
    result+=dd
    for i in range(1,10):
        if result % 10 == 0:
            break
        result+=1
        
print(result+buf)

Submission status: Accepted

Solution code:
tList = []
for i in range(5):
  tList.append(list(str(input())))

dList = []
for i in range(len(tList)):
  tmp = 10 - int(tList[i][-1])
  if tmp == 10:
    dList.append(0)
  else: 
    dList.append(tmp)

result = 0
for i in range(len(tList)):
  result += int(''.join(tList[i]))+dList[i]

print(result - sorted(dList,reverse = True)[0])

Submission status: Accepted

Solution code:
l = [input() for _ in [0] * 5]
keta =[]
for i in l:
    keta.append(i)
#print(keta)
xxx = []
for j in keta:
    if int(j[-1]) != 0:
        xxx.append(int(j) + (10 - int(j[-1])))
    else:
        xxx.append(int(j))
#print(xxx)
yyy = []
for k in keta:
    yyy.append(int(k[-1]))
#print(yyy)
zzz = []
for m in yyy:
    if int(m) > 0:
        zzz.append(m)
#print(zzz)
if 0 < sum(zzz):
    p = min(zzz)
    print(sum(xxx) - (10 - p))
else:
    p = 0
    print(sum(xxx))

Submission status: Accepted

Solution code:
import math
t=[0]*5
s=[0]*5
ans=0
for i in range(5):
    t[i]=int(input())
    s[i]=math.ceil(t[i]/10)*10-t[i]
    ans+=math.ceil(t[i]/10)*10
print(ans-max(s))

Submission status: Accepted

Solution code:
X=[int(input()) for i in range(5)]
Y=[]
for x in X:
  Y.append(-(-x//10)*10-x)
print(sum(X)+sum(Y)-(max(Y)))

Submission status: Accepted

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

last = min((m[i] - 1) % 10 + 1 for i in range(5))
sum = sum(math.ceil(m[i] / 10) * 10 for i in range(5))

print(sum+last-10)

Submission status: Accepted

Solution code:
import math

time = [int(input()) for _ in range(5)]
ans = 0
min_ones = 10

for t in time:
    ans += math.ceil(t / 10) * 10
    ones = int(str(t)[-1])
    if ones < min_ones and ones > 0:
        min_ones = ones

if min_ones != 10:
    ans = ans - (10 - min_ones)

print(ans)

Submission status: Accepted

Solution code:
from itertools import permutations


def main():
    result = 700
    cooking_time = []
    for _ in range(5):
        cooking_time.append(int(input()))
    for permutation in permutations(cooking_time, 5):
        tmp = 0
        for i in range(4):
            if not permutation[i] % 10 == 0:
                tmp += (permutation[i] // 10 + 1) * 10
            else:
                tmp += permutation[i]
        result = min(result, tmp + permutation[-1])
    print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
x = [int(input()) for i in range(5)]
ans = 0
gap = []
for i in x:
    y = -i//10 * -10
    ans += y
    gap.append(y-i)
ans = ans - max(gap)
print(ans)

Submission status: Accepted

Solution code:
from itertools import permutations
lst = [int(input()) for _ in range(5)]
lst_per = list(permutations(lst))
min_time = 643
for x in lst_per:
    ttl_time = 0
    for i in range(len(x)):
        if i != 4:
            ttl_time += x[i]
            if ttl_time % 10 != 0:
                ttl_time = (ttl_time // 10 + 1) * 10
        else:
            ttl_time += x[i]
    if ttl_time < min_time:
        min_time = ttl_time

print(min_time)

Submission status: Accepted

Solution code:
import math
x=[int(input()) for i in range(5)]
y=[i%10 for i in x]
#print(y)
ans=0
for i in range(5):
    ans+=math.ceil(x[i]/10)*10
#print(ans)
check=10
for i in range(5):
    if y[i]!=0:
        check=min(check,y[i])
if check==10:
    print(ans)
else:
    print(ans-(10-check))

Submission status: Accepted

Solution code:
import itertools

x = [int(input()) for i in range(5)]
y = list(itertools.permutations(x))
t = 130 * 5
for z in y:
   c = [z[i] if i==4 or z[i]%10==0 else int(z[i]/10+1)*10 for i in range(5)]
   tt = sum(c)
   t = min(t, tt)
print(t)

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

DISH = [int(readline()) for _ in range(5)]
Ceiled = [(i + 9) // 10 * 10 for i in DISH]
div = [y - x for x, y in zip(DISH, Ceiled)]

print(sum(Ceiled)-max(div))

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


DISH = list(map(int, read().split()))

temp = 10
im = 0
for num, i in enumerate(DISH):
    if i % 10 < temp and i % 10 != 0:
        temp = i % 10
        im = num

ans = 0
for num, i in enumerate(DISH):
    if num != im:
        ans += ((i + 9) // 10) * 10
    else:
        ans += i
print(ans)

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import numpy as np

DISH = list(map(int, read().split()))

temp = 10
im = 0
for num, i in enumerate(DISH):
    if i % 10 < temp and i % 10 != 0:
        temp = i % 10
        im = num

ans = 0
for num, i in enumerate(DISH):
    if num != im:
        ans += ((i + 9) // 10) * 10
    else:
        ans += i
print(ans)

Submission status: Accepted

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

dif = 0
ans = 0
for i in l:
    if i % 10 == 0:
        ans += i
    else:
        ans += i + (10 - i % 10)
        dif = max(dif, 10 - i % 10)
print(ans - dif)

Submission status: Accepted

Solution code:
import itertools

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

P = list(itertools.permutations([A, B, C,D,E]))
time = 0
mini = 10**3
for i in P:
    count = 0
    for j in i:
        time += j
        if (count ==4):
            break
        if j % 10 != 0:
            time += 10 - (time % 10)
        count += 1
    mini = min(mini, time)
    time = 0

print(mini)

Submission status: Accepted

Solution code:
from math import ceil
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

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

gap =10 -  max(A,B,C,D,E)

ans = ceil(a/10)*10+ceil(b/10)*10+ceil(c/10)*10+ceil(d/10)*10+ceil(e/10)*10+gap-10
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
A = []
for _ in range(5) :
  A.append(int(input()))

pmax = 0
sumA = 0
for i in range(5) :
  p = 0
  while A[i]%10 != 0 :
    A[i] += 1
    p += 1
  sumA += A[i]
  pmax = max(pmax, p)

print (sumA - pmax)

Submission status: Accepted

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

*d, = map(lambda x: 0 if x%10 == 0 else 10-x%10, menus)

ans = 0
for _m, _d in zip(menus, d):
    ans += _m+_d

print(ans-max(d))

Submission status: Accepted

Solution code:
def stupid(a):
    from itertools import permutations
    ret = float('inf')
    for p in permutations(a):
        time = 0
        for dish in p:
            time += (10 - (time % 10)) % 10
            time += dish
        ret = min(ret, time)
    return ret

def fast(a):
    temp = a[::]
    temp.sort(key=lambda x: (10 - (x % 10)) % 10)
    ret = 0
    for dish in temp:
        ret += (10 - (ret % 10)) % 10
        ret += dish
    return ret

def stress(n):
    from random import randint
    for _ in range(n):
        a = [randint(1, 123) for _ in range(5)]
        expected = stupid(a)
        got = fast(a)
        if got != expected:
            raise Exception('%s -> expected:%d, got:%d' % (' '.join(map(str, a)), expected, got))

test = False
if test:
    stress(1000)
else:
    a = [int(input()) for _ in range(5)]
    print(fast(a))

Submission status: Accepted

Solution code:
def stupid():
    from itertools import permutations

    ret = float('inf')
    for p in permutations(a):
        time = 0
        for dish in p:
            time += (10 - (time % 10)) % 10
            time += dish
        ret = min(ret, time)
    return ret

a = [int(input()) for _ in range(5)]
print(stupid())

Submission status: Accepted

Solution code:
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
sub = min([m % 10 for m in [a,b,c,d,e] if m % 10 != 0] + [10])
time = 10 * (math.ceil(a / 10) + math.ceil(b / 10)+ math.ceil(c / 10)+ math.ceil(d / 10)+ math.ceil(e / 10)) - (10 - sub)
print(int(time))

Submission status: Accepted

Solution code:
l = []
l1 = []
for i in range(5):
  a = int(input())
  l.append((a,a%10))
l.sort(key = lambda x: x[1])

count = 0
for i in range(5):
  if l[i][1] == 0:
    count += l[i][0]
    if i == 4:
      c = 5
  else:
    c = i
    break
for i in range(4,c-1,-1):
  
  if i == c:
    count += l[i][0]
  else:
    count += l[i][0] + 10-l[i][1]
print(count)

Submission status: Accepted

Solution code:
import math

# Check


def main():
    N = 5
    dishes = [0] * N
    m = 10 ** 9
    m_index = -1

    for i in range(N):
        dishes[i] = int(input())

    for i in range(len(dishes)):
        if m > dishes[i] % 10 and dishes[i] % 10 != 0:
            m = dishes[i] % 10
            m_index = i

    if m_index == -1:
        print(sum(dishes))
    else:
        print(sum([d // 10 * 10 + 10 if d % 10 != 0 else d for i, d in enumerate(dishes) if i != m_index]) + dishes[m_index])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math
import numpy as np
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

a = []
for _ in range(5):
    a.append(ni())
a = np.array(a)

m = np.min((a-1)%10+1)
d = (a - 1) // 10 + 1
print(sum(d)*10 + m - 10)

Submission status: Accepted

Solution code:
from decimal import *

dishes = []
for i in range(5):
    dishes.append(input())
    
idx = 0
min_ones_place = 9

for j in range(5):
    ones_place = int(dishes[j][-1])
    if ones_place != 0:
        if ones_place < min_ones_place:
            min_ones_place = ones_place
            idx = j
            
last_dish = int(dishes.pop(idx))

total_time = 0
for k in range(4):
    total_time += int(dishes[k])
    if total_time % 10 == 0:
        pass
    else :
        total_time = int(Decimal(str(total_time)).quantize(Decimal('1E1'), rounding=ROUND_UP))

total_time += last_dish
print(total_time)

Submission status: Accepted

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

dishes = sorted(dishes, key=lambda x: 10 - int(str(x)[-1]))
a = list()
b = list()
for d in dishes:
    if d % 10 == 0:
        a.append(d)
    else:
        b.append(d)
if len(b) > 0:
    b = [d + 10 - d % 10 for d in b[:-1]] + [b[-1]]
dishes = a + b
print(sum(dishes))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
order = [int(input()) for _ in range(5)]
max_order = [ -(-i//10)*10-i  for i in order]
print(sum(order)+sum(max_order)-max(max_order))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

ans = 0
tmp = [A, B, C, D, E]
Y = []
Z = []
for i in range(5):
    Y.append([tmp[i] % 10, tmp[i]])
Y.sort()
#print(Y)
for i in range(5):
    if Y[i][0] != 0:
        Z.append(i)
if len(Z) != 0:
    for i in range(5):
        X = Y[i][1]
        #print(i)
        while X % 10 != 0:
            X += 1
        ans += X
        #print(X)
        #print(ans)
    G = Y[Z[0]][1]
    while G % 10 != 0:
        G += 1
    ans -= G
    ans += Y[Z[0]][1]
    #print(tmp[0])
else:
    ans = sum(tmp)
print(ans)

Submission status: Accepted

Solution code:
import math

time = []
res = 0

for _ in range(5):
    time.append(int(input()))
for i in time:
    res += math.ceil(i/10) * 10
a = min([(i-1)%10 for i in time])
print(res-9+a)

Submission status: Accepted

Solution code:
I = ["{0:03d}".format(int(n)) for n in open(0).read().split()]
c = 0
min_z = 10
for i in I:
    x, y, z = map(int, i)
    if 0 < z < min_z:
        min_z = z
    if 0 < z:
        y +=1
    if 9 < y:
        x += 1
        y -= 10
    n = x * 100 + y * 10
    c += n

print(c+min_z-10)

Submission status: Accepted

Solution code:
import itertools

a_L = []

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

def hosei(x):
    """int:x"""
    x = -(x // -10)
    return x*10

a_L = list(itertools.permutations(a_L))

ans_L = []

for c in a_L:
    times = 0
    counter = 0
    for i in c:
        if counter != 4:
            times += hosei(i)
        else:
            #print(aaa)
            times += i
        counter += 1
    ans_L.append(times)

print(min(ans_L))

Submission status: Accepted

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

smallest_ones_place = 10
last_dish = 0
for i in range(5):
    if l[i]%10 != 0 and l[i]%10 < smallest_ones_place:
        smallest_ones_place = l[i]%10
        last_dish = i

total_time = l.pop(last_dish)
for j in l:
    if j%10 == 0:
        total_time += j
    else:
        total_time += (j+10-j%10)

print(total_time)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
X=[A,B,C,D,E]
Y=[]
for i in range(5):
  Y.append((((-1)*X[i])//10)*(-10))

ans=sum(Y)
for i in range(5):
  x=sum(Y)-Y[i]+X[i]
  ans=min(ans,x)
print(ans)

Submission status: Accepted

Solution code:
order = [int(input()) for _ in range(5)]
tmp=0
diff = 10
for i in order:
  if i%10 != 0:
    diff = min(i%10, diff)
    tmp+=((i//10)+1)*10
  else:
    tmp+=i
print(tmp+diff-10)

Submission status: Accepted

Solution code:
from math import floor, ceil
a = [int(input()) for i in range(5)]
c = sorted(a, key = lambda x: 10 if x % 10 == 0 else x % 10)
ans = c[0]
for i in c[1:]:
  ans += ceil(i/10) * 10
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
def main():
	# a,b,k = map(int,input().split())
	# n,k = map(int,input().split())
	dish = []
	for i in range(5):
		dish.append(input())
	# a = list(map(int,input().split()))
	# rsp = list(str(input()))
	# l = [list(map(int, input().split())) for _ in range(5)]
	# s = list(s)
	
	import itertools
	kumi = list(itertools.permutations(dish,5))
	# print(kumi)
	time = 0
	time_ans = []
	for i in range(len(kumi)):
		# print("---i = {}---".format(i))
		time += int(kumi[i][0])
		# print("dish 0's time = {}".format(time))
		while time % 10 != 0:
			time += 1
		time += int(kumi[i][1])
		# print("dish 1's time = {}".format(time))
		while time % 10 != 0:
			time += 1
		time += int(kumi[i][2])
		# print("dish 2's time = {}".format(time))
		while time % 10 != 0:
			time += 1
		time += int(kumi[i][3])
		# print("dish 3's time = {}".format(time))
		while time % 10 != 0:
			time += 1
		time += int(kumi[i][4])
		# print("dish 4's time = {}".format(time))
		
		time_ans.append(time)
		time = 0
	print(min(time_ans))


 
if __name__ == '__main__':
	main()

Submission status: Accepted

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

data_list = [A,B,C,D,E]
last_tmp = 10
last = 0
for data in data_list:
    data_str = str(data)
    if int(data_str[len(data_str)-1]) != 0:
        if last_tmp >= int(data_str[len(data_str)-1]):
            last = data
            last_tmp = int(data_str[len(data_str)-1])

if last != 0:
    data_list.remove(last)
ans = last
for data in data_list:
    ans += data
    data_str = str(data)
    if int(data_str[len(data_str)-1]) != 0:
        ans += 10-int(data_str[len(data_str)-1])

print(ans)

Submission status: Accepted

Solution code:
a=[]
b=[]
for i in range(5):
    x=int(input())
    a.append(x)
    if x%10!=0:
        b.append(10-x%10)
if a[0]%10==0 and a[1]%10==0 and a[2]%10==0 and a[3]%10==0 and a[4]%10==0:
    print(sum(a))
else:
    b.sort()
    print(sum(a)+sum(b)-max(b))

Submission status: Accepted

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

targetnum=999
minnum=10
for num,i in enumerate(arr):
    if int(str(i)[-1])<minnum and int(str(i)[-1])>0:
        minnum=int(str(i)[-1])
        targetnum=num

result=0
for num,i in enumerate(arr):
    if num==targetnum:
        result+=i
        #print("aa")
    else:
        result+=math.ceil(i/10)*10


print(result)

Submission status: Accepted

Solution code:
# Five Dishes

# input
menu = list()
for _ in range(5):
    x = int(input())
    if x % 10 != 0:
        t = x % 10
    else:
        t = 10
    menu.append([t, x])

menu = sorted(menu, reverse = True)
# print(menu)
total = 0
for e in menu[:-1]:
    if e[0] == 10:
        total += e[1]
    else:
        total += (e[1] + (10 - e[0]))
total += menu[-1][1]

print(total)

Submission status: Accepted

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

for i in range(5):
    a10 = 0
    if str(a[i])[-1] != '0':
        a10 = (10 - int(str(a[i])[-1]))
        delta.append(a10)
        count += 0
    time += a[i] + a10

if count == 0:
    delta.append(0)

print(time-max(delta))

Submission status: Accepted

Solution code:
A = [int(input()) for _ in range(5)]
A.sort(key=lambda a: (a+9)%10)
print(10 * (sum(map(lambda a: a//10, A)) + sum(map(lambda a: int(a%10!=0), A[1:]))) + A[0]%10)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
q=min((a-1)%10,(b-1)%10,(c-1)%10,(d-1)%10,(e-1)%10)+1
s=((a+9)//10+(b+9)//10+(c+9)//10+(d+9)//10+(e+9)//10)*10-10+q
print(s)

Submission status: Accepted

Solution code:

T=[[0,0] for i in range(5)]


for i in range(5):
    temp=int(input())
    if temp%10==0:
        T[i]=[10,temp]
    else:
        T[i]=[temp%10,temp]

T.sort(reverse=True)

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

ans+=T[4][1]

print(ans)

Submission status: Accepted

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

lst1 = []
min1 = 9
num1 = 0

for i, l in enumerate(lst):
    lst1.append(math.ceil(l/10)*10)
    if min1 > l%10 and l%10!=0:
        min1 = l%10
        num1 = i
lst1[num1] = lst[num1]

print(sum(lst1))

Submission status: Accepted

Solution code:
l=[]
l.append(int(input()))
l.append(int(input()))
l.append(int(input()))
l.append(int(input()))
l.append(int(input()))
t=[]
for e in l:
    t.append(e%10)
s=0
i=0
while 0 in t:
    j=t.index(0)
    t[j]=-1
    s+=l[j]
    i+=1
while i<4:
    j=t.index(max(t))
    t[j]=-1
    s+=l[j]-l[j]%10+10
    i+=1
if i==4:
    j=t.index(max(t))
    s+=l[j]
print(s)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
def x(i):
    return -(-i//10)*10
def y(i):
    return -i%10

print(x(a) + x(b) + x(c) + x(d) + x(e) - max([y(a), y(b), y(c), y(d), y(e)]))

Submission status: Accepted

Solution code:
just=[]
left=[]
for i in range(5):
  a=int(input())
  if a%10 == 0:
    just.append(a)
  else:
    left.append(a)
_sum = sum(just)    
_min=10
index=-1
for i in range(len(left)):
  i1=left[i]%10
  if _min > i1:
    _min = i1
    index = i
for i in range(len(left)):
  if i == index:
    _sum += left[i]
  else:
    b=left[i]%10
    _sum += left[i] + (10-b)
print(_sum)

Submission status: Accepted

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

Submission status: Accepted

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

m = 10
for i in [a, b, c, d, e]:
    if i%10 != 0 and i%10<m:
        m = i%10


m = 10 - m


total = 0
for i in [a, b, c, d, e]:
    if i % 10 != 0:
        total += (i//10)*10+10
    else:
        total += i
print(total-m)

Submission status: Accepted

Solution code:
lst = [int(input()) for i in range(5)]
tmp = 99
idx = 0
ans = 0

for i in range(5):
    if lst[i] % 10 != 0 and tmp > lst[i] % 10:
        tmp = lst[i] % 10
        idx = i

for i in range(5):
    if i != idx:
        if lst[i] % 10 != 0:
            lst[i] += (10 - lst[i] % 10)
        ans += lst[i]


ans += lst[idx]
print(ans)

Submission status: Accepted

Solution code:
from math import ceil

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

x = [a, b, c, d, e]
x1 = list(map(lambda x:x%10, x))
last_x = 10
last_i = -1
cnt = 0
for i in range(len(x1)):
    if x1[i]==0:
        cnt+=1
        continue
    if last_x > x1[i]:
        last_x = x1[i]
        last_i = i

if cnt==5:
    print(sum(x))
    exit(0)

tmp = x[:last_i] + x[last_i+1:]
ans = sum(list(map(lambda a:10*ceil(a/10), tmp)))+x[last_i]
print(ans)

Submission status: Accepted

Solution code:
def abc(n):

    if n%10 != 0:
        for i in range(1,14):
            if 0<10*i-n<10:
                return 10*i
    else:
        return n

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

lst1 = []
for i in range(5):
    lst1.append(abc(x[i]))

lst2 = []
for i in range(5):
    lst2.append(abc(x[i])-x[i])

print(sum(lst1)-max(lst2))

Submission status: Accepted

Solution code:
import itertools
costs = [int(input()) for _ in range(0, 5)]
ans = 1000000000000
for x in itertools.permutations([0, 1, 2, 3, 4]):
  c = 0
  for i in range(0, 5):
    c += costs[x[i]]
    if i != 4 and c % 10 != 0:
      c += 10 - c % 10
  ans = min(c, ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


print(num+min_num-10)

Submission status: Accepted

Solution code:
import math
n=[]
for i in range(5):
  n.append(int(input()))
l=[]
for i in range(5):
  l.append(10*(math.ceil(n[i]/10)))
samax=0
for i in range(5):
  ans=l[i]-n[i]
  samax=max(ans,samax)
print(sum(l)-samax)

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


A = [int(sys.stdin.buffer.readline()) for _ in range(5)]

ans = INF
for last_i in range(5):
    cnt = 0
    for i in range(5):
        if i == last_i:
            continue
        cnt += math.ceil(A[i] / 10) * 10
    cnt += A[last_i]
    ans = min(ans, cnt)

print(ans)

Submission status: Accepted

Solution code:
#--import&define---------------------
import math

def yes():
    print("Yes")
def no():
    print("No")
#--my_library--------------------------------
#mapを利用した入力
# x,y = map(int,input().split())

#forを利用した入力
#l = []
#for i in range():
#    l.append(int(input()))

#intの最大値
#x = 2147483647
#--以下解答---------------------------------
l = []
x = 2147483647
index = 0
for i in range(5):
   l.append( int(input()) )
   n = int(l[i]%10)
   if n>0 and n<x:
      x = n
      index = i

ans = 0
for i in range(5):
    if i == index:
        ans += l[i]
    elif l[i]%10 != 0:
        ans += int(l[i]/10)*10 +10
    else:
        ans += l[i]

print(ans)

Submission status: Accepted

Solution code:
a = [int(input()) for _ in range(5)]
b = []
ans = 0
for i in range(5):
    if a[i] % 10 == 0:
        ans += a[i]
    else:
        b.append([a[i], a[i] % 10])
sorted_b = sorted(b, key=lambda x: x[1], reverse=True)

for i in range(len(sorted_b)):
    if i == len(sorted_b) - 1:
        ans += sorted_b[i][0]
    else:
        ans += sorted_b[i][0] + (10 - sorted_b[i][1])
print(ans)

Submission status: Accepted

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

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

lis = [a,b,c,d,e]
mod = [a%10, b%10, c%10, d%10, e%10]

try:    
    hasu = min([i for i in mod if i%10 != 0])
    ishasu = True
except:
    hasu = 0
    ishasu = False

ans = 0
for i in range(5):
    if lis[i]%10 == 0:
        ans += lis[i]//10
    else:
        ans += (lis[i]//10 + 1)


if (not ishasu):
    print(ans*10+hasu)
else:
    print(ans*10+hasu -10)

Submission status: Accepted

Solution code:
T = [int(input()) for _ in range(5)]
T_0 = [t for t in T if t % 10 == 0]
T_non_0 = [t for t in T if t % 10 != 0]
T_non_0.sort(key=lambda x: x % 10)

time = 0
time += sum(T_0)
head = 1
for t in T_non_0:
    if head:
        time += t
        head = 0
    else:
        time += -(-t // 10) * 10

print(time)

Submission status: Accepted

Solution code:
def examA():
    X = [I() for _ in range(5)]
    k = I()
    X.sort()
    ans = "Yay!"
    if X[-1]-X[0]>k:
        ans = ":("
    print(ans)
    return

def examB():
    X = [I() for _ in range(5)]
    ans = 0
    for i in range(5):
        ans += (X[i]+9)//10 *10
        X[i] = (X[i]-1)%10
    ans -= (9-min(X))
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()

Submission status: Accepted

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

import itertools

ans = 10 ** 9 + 7
for order in itertools.permutations(range(5)):
    ans_tmp = 0
    for i in range(5):
        if ans_tmp % 10 > 0:
            ans_tmp += (10 - (ans_tmp % 10))
        ans_tmp += X[order[i]]
    ans = min(ans, ans_tmp)

print(ans)

Submission status: Accepted

Solution code:
def solve():
    dishes = list(map(int, open(0).read().split()))
    
    last = 0
    dt_max = 0
    for i in range(5):
        if dishes[i] % 10 != 0 and dt_max <= 10 - (dishes[i] - dishes[i] // 10 * 10):
            dt_max = 10 - (dishes[i] - dishes[i] // 10 * 10)
            last = i
    
    ans = 0
    for i in range(5):
        if i != last:
            if dishes[i] % 10 != 0:
                ans += 10 * (dishes[i] // 10 + 1)
            else:
                ans += dishes[i]
        else:
            ans += dishes[i]
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import math

l = [int(input()) for i in range(5)]
c = [l[i] % 10 for i in range(5)]
index = 0
minimum = 10
for i in range(5):
    if c[i] != 0 and c[i] < minimum:
        minimum = c[i]
        index = i
a = [10 * math.ceil(l[i] / 10) for i in range(5)]
ans = sum(a) - a[index] + l[index]
print(ans)