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 = 5*[0]
for i in range(5):
    a[i] = int(input())

h = 0
time = 0
for i in a:
    b = i // 10
    c = i % 10
    if(c == 0): time += i
    else:
        time += (b+1)*10
        if(h < 10-c): h = 10-c

print(time-h)

Submission status: Accepted

Solution code:
import math

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

last = 0
remain = 10
foods = [a, b, c, d, e]
for i in range(len(foods)):
    r = foods[i] % 10
    if r == 0:
        r = 10
    if r < remain:
        remain = r
        last = i

time = 0
for i in range(len(foods)):
    if i == last:
        continue
    time += math.ceil(foods[i] / 10) * 10

time += foods[last]
print(time)

Submission status: Accepted

Solution code:
times = [int(input()) for i in range(5)]
def marume(i):
    return i-1-(i-1)%10+10 

a=0
for idx,t in enumerate(times):
  if idx == ([(t-1)%10for t in times]).index(min([(t-1)%10for t in times])):
    a += t
  else :
    a += marume(t)
    
print(a)

Submission status: Accepted

Solution code:
x = []
for i in range(5):
  a = int(input())
  x.append(a)
def kiriage(n):
  if n%10 == 0:
    return n
  else:
    return (n//10 + 1)*10
ans = 0
m = 0
for xi in x:
  kx = kiriage(xi)
  ans += kx
  if kx-xi > m:
    m = kx -xi
print(ans-m)

Submission status: Accepted

Solution code:
s = [int(input()) for i in range(5)]
c =10
n = 0
for i in range(5):
    t =s[i] % 10
    if t != 0 and c > t:
        c = t
    
    if t == 0:
        n += s[i]
    else:
        n += 10 *((s[i]//10)+1)

print(n - (10 - c))

Submission status: Accepted

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

min_r_t = 12
min_r_t_index = -1
for i, t in enumerate(ts):
    r_t = t % 10
    if r_t == 0:
        continue
    if r_t < min_r_t:
        min_r_t_index = i
        min_r_t = r_t

sum_t = 0
for i, t in enumerate(ts):
    if t % 10 == 0:
        sum_t += t
    elif i == min_r_t_index:
        sum_t += t
    else:
        sum_t += ((t // 10) + 1) * 10

print(sum_t)

Submission status: Accepted

Solution code:
time = []

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

cr = 0
mr = 0
ans = 0
for t in time:
    r = t % 10
    if r != 0:
        cr += 1
        if mr == 0:
            mr = r
        else:
            mr = min(mr, r)
    ans += (t-r)

if cr == 0:
    print(ans)
else:
    ans += (10*(cr-1)+mr)
    print(ans)

Submission status: Accepted

Solution code:


def start_process(length, num):

    print(ans)

def main():
    ans = 0
    data = [int(input()) for i in range(5)]
    min_data = 10
    for i in range(5):
        if 0 < data[i] % 10 < min_data:
            min_data = data[i] % 10

    for i in range(5):
        ans = ans + (data[i] // 10)
        if data[i] % 10 > 0:
            ans += 1
    #     print(ans)
    # print(min_data)
    print((ans - 1) * 10 + min_data)

def kari():
    a = list(map(int, input().split()))
    a, b = map(int, input().split())

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
abcde = [a, b, c, d, e]
mini = (10, 0)
for i, x in enumerate(abcde):
  if x % 10 != 0 and mini[0] > x % 10:
    mini = (x % 10, i)
ans = 0
for i, x in enumerate(abcde):
  if mini[1] == i:
    ans += x
  else:
    if x % 10 == 0:
      ans += x
    else:
      ans += (x // 10 + 1) * 10
print(ans)

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]
M=[]
for i in X:
   M.append((10-i%10)%10)

ans=0

for i in X:
    ans+=(i+((10-i%10)%10))

print(ans-max(M))

Submission status: Accepted

Solution code:
import itertools

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


l = ['a', 'b', 'c', 'd', 'e']
res = 10 ** 9
for v in itertools.permutations(l):
    tmp = 0
    for i in v:
        if tmp%10 != 0:
            tmp += (10 - tmp%10)
            
        if i == 'a':
            tmp += a
        elif i == 'b':
            tmp += b
        elif i == 'c':
            tmp += c
        elif i == 'd':
            tmp += d
        else:
            tmp += e
            
    res = min(res, tmp)
    
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l=[]
t=0
for i in range(5):
  p=int(input())
  t+=p
  l.append(p%10)
l=sorted(l)
b=False
o=0
for i in l:
  if i!=0:
    if b==False:
      o=i
      b=True
    else:
      t+=10-i
  else:
    pass
print(t)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
from queue import Queue
# import numpy as np
INF = float("inf")


def solve(A: int, B: int, C: int, D: int, E: int):
    ryouri = [A, B, C, D, E]
    a = [x % 10 for x in ryouri if x % 10 != 0]
    if len(a) == 0:
        print(sum([10*(math.ceil(x/10.0)) for x in ryouri]))
    else:
        print(sum([10*(math.ceil(x/10.0)) for x in ryouri]) - (10-min(a)))

    # print(A, B, C, D, E)
    # print(A+B+C+D+E)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    solve(A, B, C, D, E)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = [int(input()) for _ in range(5)]
ans = 0
f = 0
for x in a:
    if x % 10:
        ans += x + 10 - x % 10
        f = 1
    else:
        ans += x
if f:
    ans -= 10
    ans += min([x % 10 for x in a if x % 10])
print(ans)

Submission status: Accepted

Solution code:
A = [int(input()) for _ in range(5)]
 
y = min([10] + [x%10 for x in A if x%10])
 
print(sum([10*(x//10 + bool(x%10)) for x in A]) -10 + y)

Submission status: Accepted

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

sum = math.ceil(a/10)+math.ceil(b/10)+math.ceil(c/10)+math.ceil(d/10)+math.ceil(e/10)
sum = sum*10

a = min((a-1)%10,(b-1)%10,(c-1)%10,(d-1)%10,(e-1)%10)+1

sum = sum - (10-a)
print(sum)

Submission status: Accepted

Solution code:
def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int,ss_raw()))


poss = []
for i in range(5):
    p = int_raw()
    poss.append(p)

def main(t,flags):
    if not (False in flags):
        return t
    ot = ((t+9)//10)*10
    mint = 10**10
    for i in range(5):
        if flags[i]==False:
            f = list(flags)
            f[i]=True
            mint = min(mint,main(ot+poss[i],f))
    return mint

print(main(0,[False]*5))

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:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
ans=[a,b,c,d,e]
stack=0
m=0
for i in ans:
  stack+=(10-i%10)%10
  m=max(m,(10-i%10)%10)
print(sum(ans)+stack-m)

Submission status: Accepted

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

ans = 0

temp = 10

for a in A:
    if a % 10 == 0:
        ans += a
    else:
        ans += 10 * (a // 10 + 1)
    
    temp2 = a % 10
    if temp2 != 0 and temp2 < temp:
        temp = temp2

print(ans - (10 - temp))

Submission status: Accepted

Solution code:
dishes=[int(input()) for i in range(5)]
dishes_up=[((dish+9)//10)*10 for dish in dishes]
mod=[dish%10 if dish%10!=0 else 10 for dish in dishes]
v = min(mod) if min(mod)<10 else 10
print(sum(dishes_up) - (10-v))

Submission status: Accepted

Solution code:
import math
ABCDE = [int(input()) for _ in range(5)]
print(
    sum([10 * math.ceil(_ / 10)
         for _ in ABCDE]) + min([10] + [_ % 10 for _ in ABCDE if _ % 10]) - 10)

Submission status: Accepted

Solution code:
# N,M = map(int, input().split())
A = [0] * 5
A[0] = int(input())
A[1] = int(input())
A[2] = int(input())
A[3] = int(input())
A[4] = int(input())

minidx = 0
minv = A[0] % 10

for i in range(1,5):
    if A[i] % 10 == 0: continue
    if A[i] % 10 < minv:
        minv = A[i] % 10
        minidx = i

ans = 0
for i in range(5):
    if i == minidx:
        ans = ans + A[minidx]
    else:
        ans = ans + (( A[i] + 9) // 10) * 10
print(ans)

Submission status: Accepted

Solution code:
from itertools import permutations

A = [int(input()) for _ in range(5)]
ans = 10**100
for A_perm in permutations(A, 5):
    t = 0
    for dish in A_perm:
        if t % 10 != 0:
            t += 10 - t % 10
        t += dish
    ans = min(ans, t)
print(ans)

Submission status: Accepted

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

b = (a[0]-1)%10

for i in range(5):
    if (a[i]-1)%10 < b:
        b=(a[i]-1)%10

b += 1

for i in range(5):
    if a[i]%10!=0:
        a[i]=((a[i]+10)//10)*10

print(sum(a)+b-10)

Submission status: Accepted

Solution code:
import math
arr = [int(input()) for _ in range(5)]
minmod = 10
minidx = -1
time = []
for i, a in enumerate(arr):
  mod = a % 10
  mod = mod if mod > 0 else 10
  if mod < minmod:
    minmod = mod
    minidx = i
  time.append(math.ceil(a / 10) * 10)

ans = 0
for i in range(5):
  if i == minidx:
    ans += arr[i]
  else:
    ans += time[i]
print(ans)

Submission status: Accepted

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

mi = 0
for i in range(1, len(d)):
  if (d[mi] - 1) % 10 > (d[i] - 1) % 10:
    mi = i

Ans = d[mi]
for i in range(len(d)):
  if i == mi: continue
  if d[i] % 10 == 0:
    Ans += d[i]
  else:
    Ans += d[i] + 10 - (d[i] % 10)

print(Ans)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = []
if (a%10) != 0:
  li.append(a%10)
if (b%10) != 0:
  li.append(b%10)
if (c%10) != 0:
  li.append(c%10)
if (d%10) != 0:
  li.append(d%10)
if (e%10) != 0:
  li.append(e%10)
  
if li:
  min_ = min(li)
else:
  min_ = 10

count = -((-a)//10)-((-b)//10)-((-c)//10)-((-d)//10)-((-e)//10)
count = count*10
print(count-(10-min_))

Submission status: Accepted

Solution code:
l = [int(input()) for _ in range(5)]
a = [0]*5
for i in range(5):
    if 10 - l[i]%10 !=10:
        a[i] = 10 - l[i]%10
a.sort()
a.pop()
print(sum(l)+sum(a))

Submission status: Accepted

Solution code:
a=[int(input())for _ in range(5)];ans=0
for i in a:ans+=(((i-1)//10)+1)*10
r=[]
for i in a:r.append((i-1)%10+1)
r.sort()
ans-=10-r[0]
print(ans)

Submission status: Accepted

Solution code:
a = []
for i in range(5):
    a.append(int(input()))
a.sort(reverse=True)

time = 0
max_wait = 0
for item in a:
    if item % 10 != 0:
        wait = 10 - (item % 10)
        item += wait
        max_wait = max(wait, max_wait)
    time += item

time -= max_wait
print(time)

Submission status: Accepted

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

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

    l = sorted(l, key=lambda x: (x-1)%10, reverse=True)
    # print(l)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

def main(m):
    l = []
    k = 9
    get_index = 0
    for i in range(len(m)):
        t = m[i] % 10
        l.append(t)
        if t != 0 and t < k:
            get_index = i
            k = t

    wa = 0
    for i in range(len(m)):
        if i != get_index:
            wa += math.ceil(m[i] / 10) * 10
        else:
            wa += m[i]
    
    return '{}'.format(wa)

if __name__ == '__main__':
    try:
        m = []
        for i in range(5):
            m.append(int(input().strip()))
        print('{}'.format(main(m)))
    except EOFError:
        pass

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]
new = []
mini = 10
for i in range(len(li)):
    if li[i] % 10 == 0:
        new.append(li[i])
    else:
        new.append(li[i] // 10 * 10 + 10)
        if mini > li[i] % 10:
            mini = li[i] % 10
# print(new)
print(sum(new)-(10-mini))

Submission status: Accepted

Solution code:
from itertools import permutations


def solve(a, b, c, d, e):
    m = 10000
    for p in permutations([a, b, c, d, e]):
        t = 0
        for i, o in enumerate(p):
            t += o
            if i == len(p) - 1:
                break
            while t % 10 != 0:
                t += 1
        m = min(t, m)
    return m

if __name__ == "__main__":
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    print(solve(a, b, c, d, e))

Submission status: Accepted

Solution code:
abc = [int(input())+9 for x in range(5)]
print(sum([x//10 for x in abc])*10+min([x%10 for x in abc])-9)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

b = [-(-x // 10) * 10 for x in a]

import numpy as np

aa = np.array(a)
bb = np.array(b)

c = max(bb - aa)

print(sum(bb) - c)

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

m = 10
for x in X:
    if x%10==0:
        t += x
    else:
        t += (x//10+1) * 10
        m = min(m, x%10)
t = t - 10 + m
print(t)

Submission status: Accepted

Solution code:
import math
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
dish = [a, b, c, d, e]
tmp = 10
for i in range(len(dish)):
    s = dish[i] % 10
    if s < tmp and s != 0:
        tmp = s
sum = 0
for i in range(len(dish)):
    sum += math.ceil(dish[i]/10.0)*10

print(sum - 10 + tmp)

Submission status: Accepted

Solution code:
from itertools import permutations
import math
p=permutations(range(5))
l=[int(input()) for i in range(5)]
ans=10**10
for pi in p:
    res=0
    for i in range(5):
        if i==4:
            res+=l[pi[i]]
        else:
            res+=math.ceil(l[pi[i]]/10)*10
    ans=min(ans, res)
print(ans)

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())

B = [0] * 5
for i in range(5):
	B[i] = ((A[i] - 1) // 10 + 1) * 10

print(sum(B) - max(b - a for a, b in zip(A, B)))

Submission status: Accepted

Solution code:
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g


di = []

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

su = []
for i in range(5):
    su.append(di[i]%10)

m = 100000
for i in range(5):
    if m > su[i] and su[i] != 0:
        m = su[i]

last = 0
for i in range(5):
    if su[i] == m :
        last = i

time = 0
for i in range(5):
    if i != last:
        time += ((di[i]//10))*10
        if di[i] % 10 != 0:
            time += 10
    else:
        time += di[i]

print(time)

Submission status: Accepted

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


def solve(A: int, B: int, C: int, D: int, E: int):
    R = [A, B, C, D, E]
    mn = 10
    ret = 0
    count = 0
    for r in R:
        if r % 10 > 0 and r % 10 < mn:
            mn = r % 10
        if r % 10 == 0:
            count += 1
        ret += (r // 10) * 10
    ret += (5 - count) * 10
    ret -= 10 - mn
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    solve(A, B, C, D, E)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
L = [int(input()) for i in range(5)]
L = list(itertools.permutations(L))
ans = float('inf')
for i in range(len(L)):
    menu = L[i]
    time = 0
    j = 0
    while j < 5:
        if time % 10 == 0:
            time += L[i][j]
            j += 1
        else:
            time += 1
    #print(time)
    ans = min(ans,time)
print(ans)

Submission status: Accepted

Solution code:
#B問題
A=[int(input()) for i in range(5)]
a=[]
for i in range(5):
    ain = A[i]%10
    if ain == 0:
        ain+=10
    a.append(ain)
MINA=min(a)
if MINA == 10:
    print(sum(A))
else:
    flag=0
    ans=0
    for i in range(5):
        if A[i]%10==MINA and flag == 0:
            flag=1
            ans+=A[i]
        else:
            if A[i]%10==0:
                ans+=A[i]
            else:
                ans+=(A[i]+10-A[i]%10)
    print(ans)

Submission status: Accepted

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

ri = 0
r = 0
for i in range(5):
    if not a[i]%10==0:
        if r < 10 - a[i]%10:
            ri = i
            r = 10 - a[i]%10
res = 0
for i in range(5):
    if not i == ri:
        if a[i]%10==0:
            res += a[i]
        else:
            res += a[i] + 10 - a[i]%10

res += a[ri]
print(res)

Submission status: Accepted

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

U = list(map(lambda x: int(math.ceil(x/10)*10) ,T))
D = [ U[i] - T[i] for i in range(5) ]

print(sum(U)-max(D))

Submission status: Accepted

Solution code:
times=[int(input()) for _ in range(5)]
amari=[i%10 + 10*(i%10==0) for i in times]#余り0は10とみなす
kiriage=[j//10+(j%10!=0) for j in times]
minamari=min(amari)
if minamari==10:
    print(sum(times))
else:
    print(10*(sum(kiriage))-10+minamari)

Submission status: Accepted

Solution code:
from itertools import permutations
X = [int(input()) for i in range(5)]


ans = float('inf')
for perm in permutations(X):
    tmp_ans = 0
    for p in perm:
        tmp_ans += p
        if p % 10 != 0:
            tmp_ans += (10 - p % 10)

    if perm[-1] % 10 != 0:
        tmp_ans -= (10 - perm[-1] % 10)
    ans = min(ans, tmp_ans)

print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

abcde = [ni() for _ in range(5)]
wait = []
ans = 0

for i in abcde:
    if i%10 == 0:
        ans += i
        wait.append(0)
    else:
        wait.append(10 - i%10)
        ans += 10 * (i//10 + 1)
    
wait.sort()
print(ans - wait[-1])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = [0] * 5
a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a[3] = int(input())
a[4] = int(input())

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

time = sum(b)

ans = float("inf")
for i in range(5):
    temp = time - b[i] + a[i]
    ans = min(temp,ans)

print(ans)

Submission status: Accepted

Solution code:
def solve():
    A=[0]*5
    for i in range(5):
        A[i]=int(input())
    B=[(a+9) // 10 * 10 for a in A]
    C=[((a+9) // 10 * 10) - a for a in A]
    return sum(B)-max(C)

print(solve())

Submission status: Accepted

Solution code:
# coding: utf-8

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

mini = 0

for i in range(5):
    if ts[i] % 10 < ts[mini] % 10 and ts[i] % 10 != 0:
        mini = i

result = 0
for i in range(5):
    if i != mini:
        if ts[i] % 10 == 0:
            result += ts[i]
        else:
            result += (ts[i] // 10 + 1) * 10

result += ts[mini]

print(result)

Submission status: Accepted

Solution code:
x=[int(input()) for _ in range(5)]
res=0
mx,mi=10,-1
for i in range(5):
    if 0<x[i]%10<mx:
        mx=x[i]%10
        mi=i
#print(mx,mi)
if mx==10:
    print(sum(x))
else:
    res=0
    for i in range(5):
        if i!=mi:
            res+=(-(-x[i]//10)*10)
    res+=x[mi]
    print(res)

Submission status: Accepted

Solution code:
import sys

inputs = []
for _ in range(5):
    x = int(sys.stdin.readline())
    if x % 10 == 0:
        m = 0
    else:
        m = 10 - (x % 10)
    inputs.append((m, x))

inputs.sort()

ret = 0
for m, x in inputs[:-1]:
    ret += m + x
ret += inputs[-1][1]

print(ret)

Submission status: Accepted

Solution code:
l=[int(input()) for _ in range(5)]
m = 0
s = 0
for x in l:
  t = -(-x//10)*10
  m = max(m,t-x)
  s += t
print(s-m)

Submission status: Accepted

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

ans = 0
a = 10
for i in li:
    if i%10 < a and i%10 != 0:
        a = i%10

    if i%10 == 0:
        ans += i
    else:
        i = i//10
        i = (i+1)*10
        ans += i

print(ans+a-10)

Submission status: Accepted

Solution code:
L1=[int(input()) for _ in range(5)]
L2=[0]*5
for i in range(5):
    L2[i]=(10-L1[i])%10
    
L2.sort()

print(sum(L1)+sum(L2)-max(L2))

Submission status: Accepted

Solution code:
from itertools import permutations

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

ans = float('inf')
for perm in permutations(e):
    p = list(perm)
    t = 0
    for i in range(5):
        r = p[i] % 10
        if r == 0 or i == 4:
            t += p[i]
        else:
            t += p[i] + 10 - r
    ans = min(ans, t)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from itertools import product, permutations
from collections import defaultdict
def inpl(): return list(map(int, input().split()))

X = [0]*5
for i in range(5):
    X[i] = int(input())

ans = 10**9
for Y in permutations(X, r=5):
    tmp = 0
    for y in Y[:4]:
        tmp += y
        tmp = -(-tmp//10) * 10
    ans = min(ans, tmp + Y[-1])
print(ans)

Submission status: Accepted

Solution code:
lis = [int(input()) for i in range(5)]
ans = 0
num = 0
for nu in lis:
    if nu % 10:
        ans += 10-nu%10
        num = max(num,10-nu%10)
    ans += nu
print(ans-num)

Submission status: Accepted

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

a.sort(key = lambda x:x % 10)
su = 0
c = 0
for i in range(5):
    if a[i] % 10 == 0:
        su += a[i]
    else:
        if c == 0:
            su += a[i]
            c += 1
        else:
            su += (a[i]//10 + 1)*10
print(su)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans=0
hiku=0
for i in range(5):
    x=int(input())
    if x%10!=0:
        hiku=max(hiku,10-x%10)
    ans+=((x+9)//10)*10
print(ans-hiku)

Submission status: Accepted

Solution code:
l = [10]
s = 0
for i in range(5):
  t = input()
  if t[-1] =="0":s += int(t)
  else:
    s+=(int(t)//10)*10+10
    l.append(int(t[-1]))
if min(l) == 10:
  print(s)
else:
  print(s-10+min(l))

Submission status: Accepted

Solution code:
import itertools

a = [int(input()) for i in range(5)]
ans = float("inf")
for i in itertools.permutations(a, 5):
    time = 0
    for j in i:
        while time % 10:
            time += 1
        time += j
    ans = min(ans, time)
print(ans)

Submission status: Accepted

Solution code:
from math import ceil
a=[]
m=0
for _ in range(5):
    x=int(input())
    y=ceil(x/10)*10
    a.append(y)
    m=max(m,y-x)
print(sum(a)-m)

Submission status: Accepted

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

A=rr(5)
x = 10
for a in A:
    x = min(x,a%10 if a%10 !=0 else 10)

s = 0
for a in A:
    s += (a//10)*10
    s += 10 if a%10 != 0 else 0

print(s-10+x)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = IR(5)
    k = I()
    if max(s)-min(s) > k:
        print(":(")
    else:
        print("Yay!")
    return

#B
def B():
    s = IR(5)
    s.sort(key = lambda x:-x%10)
    ans = 0
    i = 0
    k = 0
    while 1:
        if i%10 == 0:
            ans = i+s[k]
            i += s[k]-1
            k += 1
            if k == 5:break
        i += 1
    print(ans)
    return

#C
def C():
    n = I()
    return

#D
def D():
    n = I()
    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Accepted

Solution code:
import math
def solve():
  ans = 0
  ex = 10
  for i in range(5):
    tp = int(input())
    ans += 10*math.ceil(tp/10)
    if tp%10 == 0:
      continue
    else:
      ex = min(tp%10,ex)
  if not ex == 10:
    print(ans-10+ex)
  else:
    print(ans)
solve()

Submission status: Accepted

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

num = sorted([A, B, C, D, E], key=lambda x: x[-1])
ans = 0
flag = 0
for i in num:
    if i[-1] == '0':
        ans += int(i)
    elif flag == 0:
        flag = 1
        ans += int(i)
    else:
        j = int(i) // 10 + 1
        ans += 10 * j

print(ans)

Submission status: Accepted

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

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

print(A+B+C+D+E+a+b+c+d+e-max([a,b,c,d,e]))

Submission status: Accepted

Solution code:
import math

dishes = [int(input()) for _ in range(5)]
ans = 10 ** 18
for i in range(5):
    ans = min(ans, sum(int(math.ceil(f / 10)) * 10 for j, f in enumerate(dishes) if i != j) + dishes[i])
print(ans)

Submission status: Accepted

Solution code:
q = [int(input()) for _ in range(5)]
ans = sum(q) + 10000
for i in range(5):
    m = 0
    for j in range(5):
        if i == j:
            m += q[i]
        else:
            if q[j]%10 == 0:
                m += q[j]
            else:
                m += (q[j]//10+1)*10
    ans = min(ans,m)

print(ans)

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:
A = [input() for _ in range(5)]
print sum((a+9)/10*10 for a in A) - max((a+9)/10*10-a for a in A)

Submission status: Runtime Error

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

d = [abs(d % 10 -10) for d in dishes if d % 10 != 0] # select nums which can be divided by 10
d.remove(max(d)) 
print(sum(dishes) + sum(d))

Submission status: Runtime Error

Solution code:
import sys
a = list(sys.stdin.read().split())
t = [[int(n[:-1] or 0), int(n[-1])] for n in a]
t = list(zip(*t))
ans = (sum(t[0]) + (len(u := list(filter(lambda n: n > 0, t[1]))) - 1)) * 10 + min(u)
print(ans)

Submission status: Runtime Error

Solution code:
a = list(sys.stdin.read().split())
t = [[int(n[:-1] or 0), int(n[-1])] for n in a]

t = list(zip(*t))

ans = (sum(t[0]) + (len(u := list(filter(lambda n: n > 0, t[1]))) - 1)) * 10 + min(u)
print(ans)

Submission status: Runtime Error

Solution code:
a = list(sys.stdin.read().split())
t = [[int(n[:-1] or 0), int(n[-1])] for n in a]
print((sum(t[0]) + (len(u := list(filter(lambda n: n > 0, t[1]))) - 1)) * 10 + min(u))

Submission status: Runtime Error

Solution code:
S = [int(input()) for _ in range(5)]
l=[]
m=10
for i in range(5):
    if (S[i]%10)<m and S[i]%10!=0:
        m=S[i]%10
        a=S[i]
        j=i
if m==10:
    a=S[0]        
for i in range(5):
    if  i!=j:
        if S[i]%10!=0:
            S[i]+=10-(S[i]%10)
        l.append(S[i])
l.append(a)
print(sum(l))