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())
input_list = [a,b,c,d,e]
ten_up_list = []
amari_list = []
total = 0
for i in input_list:
    amari = i % 10
    if amari == 0:
        ten_up_list.append(i)
    else:
        ten_up_list.append(i + 10 - amari)
        amari_list.append(amari)
for i in ten_up_list:
    total += i
if len(amari_list) != 0:
    amari_list.sort()
    total = total - 10 + amari_list[0]
print(total)

Submission status: Accepted

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

def ceil(x):
  if x%10==0:
    return x
  else:
    return (x//10*10)+10
  
perm = list(permutations([a,b,c,d,e]))
ans = 1000
for i in perm:
  ans = min(ans,sum(map(ceil, i[:4]))+i[-1])
print(ans)

Submission status: Accepted

Solution code:
import numpy as np


def min_10(num):
    if num % 10 == 0:
        return num
    else:
        return ( num // 10 + 1 ) * 10

t = []

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

min_rem = 9
min_ind = 0

for i in range(len(t)):
    rem = t[i] % 10
    if rem == 0:
        continue
    if rem < min_rem:
        min_rem = rem
        min_ind = i

sum = 0

for i in range(len(t)):
    if i == min_ind:
        continue

    sum = min_10(sum) + t[i]


sum = min_10(sum) + t[min_ind]

print(sum)

Submission status: Accepted

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

def b():
    time = []
    time_sum = 0
    nokori_sum = 0
    nokori = []
    N = 5
    for i in range(N):
        s = int(input())
        time.append(s)
        time_sum = time_sum + s
    
    for i in range(N):
        nokori.append(get_nokori(time[i]))
        nokori.sort()
    
    for i in range(N-1):
        nokori_sum = nokori_sum + nokori[i]
    print nokori_sum + time_sum


def get_nokori(cost):
    if cost % 10 == 0:
        return 0
    else:
        n = cost/10
        nokori = 10*(n+1) - cost
        return nokori


def main():
    b()
	
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math 
l = [int(input()) for i in range(5)]
m = 10
s = 0
for n in l:
        if (n%10)!=0 and (n%10)<m:
                m= n%10
n = sum([math.ceil(s/10.0)*10 for s in l])
print(n-(10-m))

Submission status: Accepted

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

time = 0
fast1 = 10
lost = False
for i in range(5):
    if s[i] % 10 != 0:
        time += (s[i]//10 + 1)*10
        lost = True
        if fast1 > s[i]%10:
           fast1 = s[i]%10
        # print(str(time)+" "+str(fast1))
    else:
        time += s[i]
if lost:
    time += fast1-10


print(time)

Submission status: Accepted

Solution code:
from sys import stdin
data = [int(stdin.readline().rstrip()) for _ in range(5)]
divs = [(i,10-d%10) if d%10 != 0 else (i, d%10) for i,d in enumerate(data)]
divs.sort(key=lambda x:x[1])
print(sum(data)+sum(list(t[1] for t in divs[0:-1])))

Submission status: Accepted

Solution code:
import numpy as np
mins = np.array([int(input()) for _ in range(5)])
min_last_dig = (min(((mins - 1) % 10) + 1)) - 10
round_mins = np.ceil(mins / 10) * 10
print(int(round_mins.sum() + min_last_dig))

Submission status: Accepted

Solution code:
import math

x = []
sum = 0
min = 0
for i in range(5):
    x = input()
    y = x % 10
    if y == 0:
        sum += x
    else:
        sum += x + 10 - y
        if min == 0:
            min = y
        elif y < min:
            min = y

if min == 0:
    print(sum)
else:
    print(sum - 10 + min)

Submission status: Accepted

Solution code:
li = [int(input()) for i in range(5)]
flag = True
for i in range(5):
    if li[i] % 10 == 0:
        flag = True
    else:
        flag = False
        break

if flag:
    print(sum(li))
else: 
    for i in range(1,10):
        for j in range(5):
            if li[j] % 10 == i:
                a = li[j]
                del li[j]
                break
        else:
            continue
        break

    for i in range(4):
        if li[i] % 10 != 0:
            li[i] = (li[i] // 10 + 1) * 10
    print(sum(li) + a)

Submission status: Accepted

Solution code:
from math import ceil
def fanc(x):
    return int((ceil(x/10))*10)
ans = 0
menu = [int(input()) for _ in range(5)]
menu.sort(key=lambda x:x%10)
for i in range(5):
    if menu[i]%10:
        ans += menu.pop(i)
        break
menu = list(map(fanc, menu))
print(ans+sum(menu))

Submission status: Accepted

Solution code:
times = [int(input()) for i in range(5)]
ans = 0
minutes = []
for i in range(len(times)):
  ans += times[i]
  if (times[i] % 10) != 0:
    minutes.append(str(times[i])[-1])

minutes.sort(reverse=True)

for j in range(len(minutes) - 1):
  ans += 10 - int(minutes[j])
print(ans)

Submission status: Accepted

Solution code:
a = []
for i in range(5):
    a.append(int(input()))
b = list(map(lambda x: 10-x%10 if x%10 != 0 else 0, a))
b = sorted(b)
print(sum(a)+sum(b[:-1]))

Submission status: Accepted

Solution code:
import collections as c
ip = lambda : map(int, input().split())

#################

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
l = [A,B,C,D,E]
sss = {0,1,2,3,4}
ans = 800
for i1 in range(5):
    s = {i1}
    for i2 in range(5):
        if i2 in s:
            continue
        s.add(i2)
        for i3 in range(5):
            if i3 in s:
                continue
            s.add(i3)
            for i4 in range(5):
                if i4 in s:
                    continue
                s.add(i4)
                for i5 in sss-s:
                    ans = min(ans,(l[i1]+9)//10*10+(l[i2]+9)//10*10+(l[i3]+9)//10*10+(l[i4]+9)//10*10+l[i5])
               
                    s-={i5}
                s-={i4}
            s-={i3}
        s-={i2}
    s-={i1}
print(ans)

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
ALL = [A,B,C,D,E]
G=[[0,0],[0,0],[0,0],[0,0],[0,0]]
for i in range(len(ALL)):
  G[i][1] = ALL[i]
  if (ALL[i]%10 == 0):
    G[i][0] = 0
  else:
    G[i][0] = 10-(ALL[i] %10)
G.sort()
total = 0
for j in range(4):
  total = total+G[j][1]+G[j][0]
total = total + G[4][1]
print(total)

Submission status: Accepted

Solution code:
a = []
b = []

for i in range(5):
    In = int(input())
    a.append(int(In/10))
    b.append(In%10)

b_notzero = [i for i in b if i != 0]
if len(b_notzero) != 0:
    b_notzero.sort()
    b_min = b_notzero[0]
    print(sum(a) * 10 + (len(b_notzero) - 1) * 10 + b_min)
else:
    b_min = 0
    print(sum(a) * 10)

Submission status: Accepted

Solution code:
list = []
for i in range(5):
    list.append(int(input()))
ans = 0
odd_l = []
for i in range(5):
    odd_l.append(list[i] % 10)
#print(odd_l)

count = 0
for i in range(5):
    if odd_l[i] == 0:
        ans += list[i]
        list[i] = 0
        odd_l[i] = 999999
        count += 1
#print(ans)

#print(list[odd_l.index(min(odd_l))])
ans += list[odd_l.index(min(odd_l))]
odd_l[odd_l.index(min(odd_l))] = 99999
#print(odd_l)

for i in range(5):
    if odd_l[i] <= 123:
        ans += (int(list[i] / 10) + 1) * 10
print(ans)

Submission status: Accepted

Solution code:
import math

rcvr = [0, 0, 0, 0, 0]
i = 0
while (i < 5):
    rcvr[i] = int(input())
    i += 1

i = 0
ceiled = [0, 0, 0, 0, 0]
dif =  [0, 0, 0, 0, 0]
while (i < 5):
    ceiled[i] = math.ceil(rcvr[i] / 10)*10
    dif[i] = rcvr[i] - ceiled[i]
    i += 1


diff = min(dif)
ans = 0
for d in ceiled:
    ans +=  d

ans += diff
print(ans)

Submission status: Accepted

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

ans = sum(li)

wareru = 0
sa = []
for i in li:
    tmp = i % 10
    if tmp == 0:
        pass
    else:
        tmp = 10-tmp
    sa.append(tmp)

ans += sum(sa)
ans -= max(sa)
print(ans)

Submission status: Accepted

Solution code:
import itertools

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

c_list = itertools.permutations(input_list)

for el_list in c_list:
    time = 0
    count = 0
    #print(el_list)
    for el in el_list:
        time += el
        if count == 4:
            break
        elif time%10 != 0:
            while True:
                time+=1
                if time%10 == 0:
                    break
        count += 1
    #print(time)
    ans.append(time)

print(min(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]
time = [0,0,0,0,0]
reg = 0
mini = 10

for l in range(5):
  num = dish[l]%10
  if num == 0:
    time[l] = dish[l]
  else:
    time[l] = int(((dish[l]-dish[l]%10)/10+1)*10)
    
  if num != 0 and num < mini:
    mini = num
    reg = l
        
if reg ==0:
  print(a+time[1]+time[2]+time[3]+time[4])
elif reg == 1:
  print(time[0]+b+time[2]+time[3]+time[4])
elif reg == 2:
  print(time[0]+time[1]+c+time[3]+time[4])
elif reg == 3:
  print(time[0]+time[1]+time[2]+d+time[4])
elif reg == 4:
  print(time[0]+time[1]+time[2]+time[3]+e)

Submission status: Accepted

Solution code:
a,b,c,d,e=[int(input()) for i in range(5)]

if a%10 == 0:
  a2 = a
else:
  a2 = ((a//10)+1)*10

if b%10 == 0:
  b2 = b
else:
  b2 = ((b//10)+1)*10

if c%10 == 0:
  c2 = c
else:
  c2 = ((c//10)+1)*10

if d%10 == 0:
  d2 = d
else:
  d2 = ((d//10)+1)*10

if e%10 == 0:
  e2 = e
else:
  e2 = ((e//10)+1)*10

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

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

listmp = [-1,-1,-1,-1,-1]
for i in range(5):
  if lis[i]==0:
    listmp[i] = 10
  else:
    listmp[i] = lis[i]
    
min_index = 0
for i in range(5):
  if listmp[i]<listmp[min_index]:
    min_index = i

lis2 = [a2,b2,c2,d2,e2]

out = sum(lis2) - lis2[min_index] + lis3[min_index]

print(out)

Submission status: Accepted

Solution code:
import numpy as np

num = [] #５個の料理の必要時間
total = 0
mini = 10
b = 1
for i in range(5): #入力
    a = input()
    a = int(a)
    b = a % 10 #bにはaの１の桁が０になったものが入る
    total += a - b
    if b != 0:
        total+=10
        if b < mini:
            mini=b


if mini== 10:
    print(total)
else:
    print(total -(10-mini))

Submission status: Accepted

Solution code:
dish = []
for i in range(5):
    dish.append(int(input()))
tmp1 = sum([d // 10 + (d % 10 > 0) for d in dish]) * 10
tmp2 = sum(sorted([d % 10 for d in dish if d % 10 > 0])[:1])
if tmp2 > 0:
    print(tmp1 + tmp2 - 10)
else:
    print(tmp1)

Submission status: Accepted

Solution code:
t = [int(input()) for i in range(5)] 
ugly = []
small = 10

total = 0
for i in t:
    remainder = i % 10
    if remainder != 0:
        ugly.append(i)
        if remainder < small:
            small = remainder
    else:
        total += i

last = True
for i in ugly:
    re = i % 10
    if re == small and last:
        total += i
        last = False
    else:
        total += i + 10 - re

print(total)

Submission status: Accepted

Solution code:
A=[int(input()) for _ in range(5)]
A_1=[(i,i%10) for i in A]
A_1.sort(key=lambda x:x[1])
ans=0
count=0
for a,b in A_1:
    if not b==0 and count==0:
        count=b
    if b==0:
        ans+=a
    else:
        ans+=a+abs(10-b)
if count==0:
    print(ans)
else:
    print(ans-abs(10-count))

Submission status: Accepted

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

i = 10
for j in {a,b,c,d,e} :
  if i>j%10 and j%10>0 :
    i = j%10
  
ans = 0
if i!=0 :
  ans = 10-i
print (-(-a//10)*10+-(-c//10)*10+-(-b//10)*10+-(-d//10)*10+-(-e//10)*10-ans)

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)

v = []
for i in range(5):
    v.append(I())

# 全探索？
# 1の位が一に一番近いものを求める
str_v = [str(i) for i in v]
min_first_digit = None
for sidx, s in enumerate(str_v):
    if s[-1] == '0':
        continue
    if min_first_digit == None:
        min_first_digit = [sidx , s[-1]]
        continue
    if s[-1] < min_first_digit[1]:
        min_first_digit = [sidx, s[-1]]

if min_first_digit == None:
    print(sum(v))
else:
    result = 0
    for vidx, item in enumerate(v):
        if vidx != min_first_digit[0]:
            result += item
            if item % 10 != 0:
                result += 10 - item % 10
    result += v[min_first_digit[0]]
    print(result)

Submission status: Accepted

Solution code:
li = [int(input()) for i in range(5)]
last = 10 - min([i % 10 for i in li if i % 10 != 0] + [10])
ans = sum([i + 10 - i % 10 if i % 10 != 0 else i for i in li]) - last
print(ans)

Submission status: Accepted

Solution code:
orders = [int(input()) for i in range(5)]
orders_first = [int(str(odr)[-1]) if str(odr)[-1]!="0" else 10 for odr in orders]
min_value = min(orders_first)
orders_add = [10 - O for O in orders_first]
print( sum(orders) + sum(orders_add) - (10 - min_value) )

Submission status: Accepted

Solution code:
a=list()
for i in range(5):
  a.append(int(input()))
flag=True
count2=0
for i in range(5):
  if a[i]%10==0:
    count2+=a[i]
  else:
    flag=False
if flag==False:
  max=10
  count=0
  for i in range(5):
    if a[i]%10<max and a[i]%10!=0:
      max=a[i]%10
      maxI=i
  for i in range(5):
    if i!=maxI:
      count+=a[i]
      if a[i]%10!=0:
        count+=(10-a[i]%10)
  count+=a[maxI]
  print(count)
else:
  print(count2)

Submission status: Accepted

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

#a = 29
#b = 20
#c = 7
#d = 35
#e = 120

intlist = []

intlist.append(a)
intlist.append(b)
intlist.append(c)
intlist.append(d)
intlist.append(e)

flagMin = [0] * 5 

Min = 0
Min_tmp = 10
tmp = 0

#print(intlist)
#print(flagMin)

for i in range(len(intlist)):
	tmp = intlist[i] % 10
	if tmp != 0:
		if tmp < Min_tmp:
			Min_tmp = tmp
			Min = intlist[i]
#print(Min)
#print(Min_tmp)

for i in range(len(intlist)):
	if intlist[i] == Min:
		flagMin[i] = 1
		break

#print(flagMin)

timelist = []

for i in range(len(intlist)):
	if flagMin[i] == 1:
		continue
	orderT = int(intlist[i] / 10)
	if intlist[i]%10 != 0:
		orderT +=1
#	print("orderMinutes:" ,intlist[i])
#	print("orderT:", orderT)
	timelist.append(orderT)

result = sum(timelist) * 10 + Min

print(result)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def func(x):
    if (x % 10 != 0):
        return (x + (10-x % 10))
    else:
        return(x)


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


lis1 = []


for i in range(5):
    lis1.append([i, int(lis[i][-1])])

lis1.sort(key=lambda x: x[1])

lis2 = lis1.copy()

for i in range(5):
    if (lis1[i][1] == 0):
        lis2.append(lis1[i])
        lis2.pop(0)

s = 0

for i in range(4):
    s += func(int(lis[lis2[4-i][0]]))

s += int(lis[lis2[0][0]])

print(s)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
ans = a + b + c + d + e
l = []
for i in a,b,c,d,e:
    k = 10-i%10
    if k != 10:
        l.append(k)
if len(l) != 0:
    l.pop(l.index(max(l)))
    ans += sum(l)

print(ans)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
n = 0
for x in (a, b, c, d, e,):
    n += -(-x // 10)*10
k = 10
for i in (a, b, c, d, e):
    j = i % 10
    if j != 0 and k > j:
        k = j
print(n - 10 + k)

Submission status: Accepted

Solution code:
from sys import stdin

num_dishes = 5
dishes = []
for i in range(5):
    dishes.append(int(stdin.readline()))
for i in range(0, num_dishes - 1):
    for j in range(i + 1, num_dishes):
        if (dishes[i] % 10 > dishes[j] % 10):
            dishes[i], dishes[j] = dishes[j], dishes[i]
dishes.sort(key=lambda d: d % 10)
got = False
ans = 0
for dish in dishes:
    if dish % 10 == 0:
        ans += dish
        continue
    else:
        if got:
            ans += dish + (10 - dish % 10)
        else:
            got = True
            ans += dish
print(ans)

Submission status: Accepted

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


high = 0
ans = 0
for i in menu:
    if i % 10 != 0:
        takai = abs(10-int(str(i)[-1]))
        #print(int(str(i)[-1]))
        #ans = ans + int(str(i)[:-1]+"0") + takai
        ans += i + takai
        if takai > high:
            high = takai
    else:
        ans += i
    #print(ans)
print(ans-high)

Submission status: Accepted

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

t = [a,b,c,d,e]
tt = [a%10, b%10, c%10, d%10, e%10]

min_i = 9
total = 0
for v in t:
  if v%10 < min_i and v%10 > 0:
    min_i = v%10
  if v%10 != 0:
    total += v + 10 - v%10
  else:
    total += v

if any(tt):
	print(total - 10 + min_i)
else:
  	print(total)

Submission status: Accepted

Solution code:
inputs = [0,0,0,0,0]
inputs[0] = int(input())

inputs[1] = int(input())

inputs[2] = int(input())

inputs[3] = int(input())

inputs[4] = int(input())


top = 10
top_i = 0

sum = 0

for i in range(5):
	if top > inputs[i] % 10 and inputs[i] % 10 != 0:
		top = inputs[i] % 10
		top_i = i

for i in range(5):
	if i != top_i:
		#print(sum)
		sum = sum + int(inputs[i] / 10) * 10
		if inputs[i] % 10 != 0:
			sum = sum + 10
sum = sum + inputs[top_i]

print(sum)

Submission status: Accepted

Solution code:
a=[0]*5
a[0]=int(input())
a[1]=int(input())
a[2]=int(input())
a[3]=int(input())
a[4]=int(input())
amari=10
for i in range(5):
  if a[i]%10!=0:
    tmp=a[i]%10
  else:
    tmp=10
  amari=min(amari,tmp)
  a[i]=(int((a[i]-1)/10) + 1)*10
print(sum(a)-10+amari)

Submission status: Accepted

Solution code:
ABCDE = [int(input()) for i in range(5)]
ABCDE.sort(key = lambda x : x % 10 if x % 10 != 0 else 10)

ans = 0
for i, element in enumerate(ABCDE):
    if i == 0:
        ans += element
    else:
        wait = 10 - element % 10 if element % 10 != 0 else 0
        ans += element + wait


print(ans)

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
s=[A,B,C,D,E]
min1=10
for i in range (0,5):
    m=s[i]%10
    if(m!=0):
        if(min1>m):
            min1=m
time=(-(-A // 10))*10+(-(-B // 10))*10+(-(-C // 10))*10+(-(-D // 10))*10+(-(-E // 10))*10-10+min1
print(time)

Submission status: Accepted

Solution code:
menu = [int(input()) for _ in range(5)]
mods = [food % 10 if food % 10 != 0 else 10 for food in menu ]
max_food = mods.index(min(mods))

times = 0

for i, food in enumerate(menu):
  if i == max_food or food % 10 == 0:
    times += food
  else:
    times += (food // 10 + 1) * 10
    
print(times)

Submission status: Accepted

Solution code:
ans = 0
temp = -1
for i in range(5):
    cur = int(input())
    if cur%10==0:
        ans += cur
    else:
        ans += cur+10-cur%10
        if temp<10-cur%10:
            temp = 10-cur%10

if temp!=-1:
    ans -= temp

print(ans)

Submission status: Accepted

Solution code:
def jikann(a,b,c,d,e):
    an=0
    amari=9
    hasuu=0
    check=0
    for i in [a,b,c,d,e]:
        an+=i // 10 * 10
        check += i % 10
        if i % 10 != 0:
            hasuu+=1
            if amari >= i % 10:
                amari = i % 10
    if check==0:
        an=sum([a,b,c,d,e])
    else:
        an=an + (hasuu - 1) * 10 + amari
    return an
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
print(jikann(a,b,c,d,e))

Submission status: Accepted

Solution code:
def f(x) :
    while x % 10 != 0 :
        x += 1
    return x
def h(x) :
    return x % 10
l = []
n = []
sum = 0
for i in range(5) :
    a = int(input())
    if a % 10 == 0 :
        sum += a
    else :
        l.append(a)
for i in l :
    n.append(h(i))
if n :
    min = n.index(min(n))
    mo = l[min]
    sum -= f(l[min])
    sum += mo
for i in l :
    sum += f(i)
print(sum)

Submission status: Accepted

Solution code:
l=[int(input()),int(input()),int(input()),int(input()),int(input())]

n=5
m=10
s=0
while n:
  s += (l[n-1]-1)//10*10+10
  a = l[n-1] % 10
  if a==0 : a =10
  if m>a : m = a
  n -= 1

print(s-10+m)

Submission status: Accepted

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

# 1のくらいが最も小さいものを最後に注文する

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

times = [a,b,c,d,e]
ones = [a1,b1,c1,d1,e1]

# 全て一緒の場合、
#if len(list(set(ones))) == 1:

ones = [10 if i==0 else i for i in ones]

sum = 0

min_index = ones.index(min(ones))
sum += times[min_index]
del times[min_index]
for i in times:
	# 1のくらいは切り上げ: 28
	if i%10==0:
		sum += i
	else:
		sum += (i//10+1)*10

print(sum)

Submission status: Accepted

Solution code:
import math
ae = [int(input()) for _ in range(5)]
if all([a%10==0 for a in ae]):
    min_ae = 0
else:
    min_ae = 9
num = 0
for a in ae:
    s = str(a)
    if s[-1] == "0":
        pass
    else:
        min_ae = min(int(s[-1]), min_ae)
    if min_ae==int(s[-1]):
        num = a
ae.remove(num)
ceil_ae = [math.ceil(a/10)*10 for a in ae]
print(num + sum(ceil_ae))

Submission status: Accepted

Solution code:
lis = []
lis2 = []
lis3 = []
mi = 100000

for i in range(5):
  a = int(input())
  lis.append(a)
  
for x in lis:
  x2 = x % 10
  if x2 == 0:
    x3 = x
  else:
    x3 = x - x2 + 10
  lis2.append(x2)
  lis3.append(x3)

for i in lis2:
  if i != 0 and i < mi:
      mi = i
if sum(lis2) == 0:
  mi = 0
su = sum(lis3)

ans = su + mi - 10

if sum(lis2) == 0:
  print(su)
else:print(ans)

Submission status: Accepted

Solution code:
a = []
s = 0
for _ in range(5):
    n = int(input())
    b, c = n // 10, n % 10

    s += b * 10
    if c != 0:
        a.append(c)

if not a:
    print(s)
else:
    print(s + 10 * (len(a) - 1) + min(a))

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
a.sort(key=lambda x: abs(int(str(x)[-1]) - 10) % 10)
result = 0
for i, t in enumerate(a):
    if i == 4:
        result += t
    else:
        result += t
        result += (10 - int(str(t)[-1])) % 10
print(result)

Submission status: Accepted

Solution code:
import itertools
a = list()
for i in range(5):
    a.append(int(input()))

time_list = list()
comb = itertools.permutations(a)
for tmp in comb:
    time_sum = 0
    # print(tmp)
    for i in range(5):
        if time_sum % 10 != 0:
            time_sum += 10 - time_sum % 10
        time_sum += tmp[i]
        # print(time_sum)
    time_list.append(time_sum)

result = min(time_list)
print(result)

Submission status: Accepted

Solution code:
min_first_digit = 10
value_list = []
value = 0
for i in range(5):
    input_lines = input().split()
    value = int(input_lines[0])
    remainder = value % 10
    if remainder == 0:
        value_list.append(value)
    elif remainder != 0:
        value_list.append(value - (value % 10) + 10)
        if remainder < min_first_digit:
            min_first_digit = remainder
            index = i
            index_value = value
            index_value_2 = value - (value % 10) + 10
if min_first_digit != 10:
    print(sum(value_list) - index_value_2 + index_value)
else:
    print(sum(value_list))

Submission status: Accepted

Solution code:
a = input()                                                             
b = input()                                                             
c = input()                                                             
d = input()                                                             
e = input()                                                             
                                                                        
orders = [a, b, c, d, e]                                                
orders = sorted(orders, key=lambda x:int(x[-1]))                        
                                                                        
a = []                                                                  
b = []                                                                  
for order in orders:                                                    
    if order[-1] == "0":                                                
        a.append(int(order))                                            
    else:                                                               
        b.append(order)                                                 
                                                                        
if len(a) == 5:                                                         
    o = sum(a)                                                          
else:                                                                   
    o = sum(a) + int(b[0]) + sum([10 - int(_b[-1])+int(_b) for _b in b[1:]])
print(o)

Submission status: Accepted

Solution code:
import math
a = []

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

s = 9
b = 0
for i in a:
    if int(str(i-1)[-1]) < s:
        s = int(str(i-1)[-1])
    
    b += math.ceil(i/10)*10
b = b - 10 + s + 1
print(str(b))

Submission status: Accepted

Solution code:
import math

i = []
for l in range(5):
    i.append(int(input()))
m = 0
l = 0
mx = -1
for x in range(5):
    if m < (10 - i[x] % 10) and 10 - i[x] % 10 != 10:
        if x != 0:
            l += math.ceil(i[mx] / 10) * 10
        m = 10 - i[x] % 10
        mx = x
    else:
        l += math.ceil(i[x] / 10) * 10
if mx != -1:
    l += i[mx]
print(l)

Submission status: Accepted

Solution code:
def dec(n):
    for i in range(14):
        if n <= 10 * i:
            return 10 * (i)

t_order = [0] * 5
for i in range(5):
    t_order[i] = int(input())
#print(t_order)
#print('---')

t_min = dec(max(t_order)) * 5
for i in range(5):
    t_sum = 0
    for j in range(5):
        if j == i:
            t_sum += t_order[j]
        else:
            t_sum += dec(t_order[j])
    #print(t_sum)

    t_min = min(t_min, t_sum)

print(t_min)

Submission status: Accepted

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

remains = {}
for i, ot in enumerate(order_time):
    remains[i] = ot % 10 if ot % 10 > 0 else 10 

total_time = 0
cnt = 0
for i, r in sorted(remains.items(), key=lambda x: -x[1]):
    if r == 10 or cnt == 4:
        total_time += order_time[i]
    else:
        total_time += order_time[i] + (10 - r)
    cnt += 1

print(total_time)

Submission status: Accepted

Solution code:
def solve(candidates):
    curr_time = 0
    candidates = sorted(candidates)
    while len(candidates) > 0:
        if curr_time % 10 != 0:
            curr_time += 10 - (curr_time % 10)
        losses = list(map(lambda c: calc_loss(curr_time, c), candidates))
        min_loss = losses[0]
        min_loss_candidate_idx = 0
        for i, loss in enumerate(losses):
            if loss <= min_loss:
                min_loss = loss
                min_loss_candidate_idx = i
        dish = candidates.pop(min_loss_candidate_idx)
        curr_time += dish
    return curr_time


def calc_loss(curr_time, candidate):
    return (10 - ((curr_time + candidate) % 10)) % 10


candidates = []
for _ in range(5):
    candidates.append(int(input()))

print(solve(candidates))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def function(n):
    if n % 10 == 0:
        return n
    else:
        return (n // 10)*10 + 10
A, B, C, D, E = (int(input()) for i in range(5))
list, ans = [(A % 10, A), (B % 10, B), (C % 10, C), (D % 10, D), (E % 10, E)], 0
for z in list:
    if z[0] == 0:
        ans += z[1]
        list.remove(z)
N = len(list)
list = sorted(list, key=lambda x:x[0])
for i in range(N-1):
    ans += function(list[N-i-1][1])
ans += list[0][1]
print(ans)

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
a.sort(reverse=True)
x=10
last=a[4]
for i in a:
    if i%10!=0 and x>i%10:
        last=i
        x=i%10
a.remove(last)

ans=last
for i in a:
    ans=ans+i+(0 if i%10==0 else 10-i%10)
print(ans)

Submission status: Accepted

Solution code:
import itertools

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
array = [A, B, C, D, E]
min_time= float('inf')

for i in list(itertools.permutations(array)):
    tmp = i[0] + ((10 - i[0]%10) if i[0] % 10 != 0 else 0)
    tmp += i[1] + ((10 - i[1]%10)  if i[1] % 10 != 0 else 0)
    tmp += i[2] + ((10 - i[2]%10) if i[2] % 10 != 0 else 0)
    tmp += i[3] + ((10 - i[3]%10) if i[3] % 10 != 0 else 0)
    tmp += i[4]
    
    min_time = min(min_time, tmp)
    
print(min_time)