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=list([int(input()) for i in range(5)])
ans=0
cnt=0
B=[]
for i in range(5):
    if A[i]%10!=0:
        B.append(A[i]%10)
for i in range(5):
    if A[i]%10==0:
        ans+=A[i]
    else:
        ans+=(A[i]//10+1)*10
        if A[i]%10==min(B) and cnt==0:
            ans-=(10-A[i]%10)
            cnt+=1
print(ans)

Submission status: Accepted

Solution code:
l=list(int(input()) for _ in range(5))
s=list(10-i%10 for i in l)
for i in range(s.count(10)):
  s.remove(10)
if len(s)>0:
  s.remove(max(s))
print(sum(l)+sum(s))

Submission status: Accepted

Solution code:
foods=[int(input()) for i in range(5)]
time=0
tmp=[]

for i in range(5):
    mod=foods[i]%10
    if mod==0:
        time+=foods[i]
    else:
        tmp.append((mod, i))

l=sorted(tmp, reverse=True)

for i in range(len(l)):

    if i != len(l)-1:
        time+=(10-l[i][0])+foods[l[i][1]]
    else:
        time+=foods[l[i][1]]
        

print(time)

Submission status: Accepted

Solution code:
import math
l=[int(input()) for i in range(5)]
ans=min(l[0]+math.ceil(l[1]/10)*10+math.ceil(l[2]/10)*10+math.ceil(l[3]/10)*10+math.ceil(l[4]/10)*10,
math.ceil(l[0]/10)*10+l[1]+math.ceil(l[2]/10)*10+math.ceil(l[3]/10)*10+math.ceil(l[4]/10)*10,
math.ceil(l[0]/10)*10+math.ceil(l[1]/10)*10+l[2]+math.ceil(l[3]/10)*10+math.ceil(l[4]/10)*10,
math.ceil(l[0]/10)*10+math.ceil(l[1]/10)*10+math.ceil(l[2]/10)*10+l[3]+math.ceil(l[4]/10)*10,
math.ceil(l[0]/10)*10+math.ceil(l[1]/10)*10+math.ceil(l[2]/10)*10+math.ceil(l[3]/10)*10+l[4])
print(ans)

Submission status: Accepted

Solution code:
lis=[]
for i in range(5):
  lis.append(int(input()))
saitei=10
keep=0
for j in range(0,5):
  if 1<=lis[j]%10<saitei:
    saitei=lis[j]%10
    keep=j+1
res=0
for k in range(0,5):
  if lis[k]%10==0:
    res+=lis[k]
  else:
    res+=lis[k]+10-lis[k]%10

print([res,res-(10-lis[keep-1]%10)][bool(keep)])

Submission status: Accepted

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

mod_min = 10
idx = 0
for i in range(5):
    mod = times[i] % 10
    if mod == 0:
        continue
    else:
        if mod < mod_min:
            idx = i
            mod_min = mod

ans = 0
for i in range(5):
    if idx == i:
        ans += times[i]
    else:
        if times[i] % 10 == 0:
            ans += times[i]
        else:
            ans += (times[i] // 10) * 10 + 10
print(ans)

Submission status: Accepted

Solution code:
import math
list=[int(input()) for x in range(5)]
list.sort(key=lambda x:x%10)
count=0
for l in list:
  if l%10==0:
    count+=1
if count==5:
  print(sum(list))
else:
  a=list[count]
  del list[count]
  ans=[]
  for t in list:
    ans.append(math.ceil(t/10)*10)
  print(sum(ans)+a)

Submission status: Accepted

Solution code:
A=list(int(input()) for _ in range(5))
B=[]
C=[]
for i in A:
    if i%10!=0:
        B.append(i%10)
        C.append((i//10+1)*10)
    else:
        C.append(i)
if len(B)>0:
    c=10-min(B)
else:
    c=0
print(sum(C)-c)

Submission status: Accepted

Solution code:
l = [int(input()) for i in range(5)]
L = []
for i in l:
  if i%10==0:
    L.append(0)
  else:
    L.append(10-i%10)
print(sum(l)+sum(L)-max(L))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def five_dishes(li):

    ans = 0
    count = 10
    for i in li:
        ans += -(-i//10)*10
        if i%10 != 0:
            count = min(count, i%10)
    return ans-(10-count) if count != 10 else ans

def main():
    li = [int(input())for i in range(5)]
    print(five_dishes(li))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = [int(input()) for i in range(5)]
b = []
for i in range(5):
  if a[i] % 10 == 0:
    b.append(10)
  else:
    b.append(a[i] % 10)
b.sort()
sum = 0
for i in range(5):
  if a[i]%10 == b[0]:
    sum = sum + a[i]
    b[0] = 0
  elif a[i] % 10 == 0:
    sum = sum + a[i]
  else:
    sum = sum + (a[i]//10)*10 + 10
print(sum)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    l=[input() for i in range(5)]
    sum=0
    for j in range(5):
        sum+=(int(l[j])//10)*10
    num=10
    for n in range(5):
        if int(l[n][-1])!=0 and int(l[n][-1]) < num:
            num=int(l[n][-1])
    sum-=10-num
    for s in range(5):
        if int(l[s])%10!=0:
            sum+=10
    print(sum)
resolve()

Submission status: Accepted

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

import math

t=[int(input()) for _ in range(5)]
r=[(i-1)%10+1 for i in t]
c=r.index(min(r))
ans=0
for i in range(5):
    if i==c:
        ans+=t[i]
    else:
        ans+=math.ceil(t[i]/10)*10
print(ans)

Submission status: Accepted

Solution code:

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

a.sort(key= lambda x: x%10)
ans = 0
cnt = 0
for i in range(5):
  if cnt == 0 and a[i] % 10 != 0:
    ans += a[i]
    cnt += 1
  else:
    ans += -(-a[i] // 10)*10

print(ans)

Submission status: Accepted

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

for x in parr:    
    if x%10 == 0:
        arr.append([0,x,x])
    else:
        arr.append([x%10, (x//10 + 1)*10,x])

arr.sort()

found = False
ans = 0
for cur in arr:
    r,v,o = cur
    if r == 0:
        ans += v
    else:
        if found:
            ans += v
        else:
            ans+= o
            found = True

print(ans)

Submission status: Accepted

Solution code:
dishes = [int(input()) for i in range(5)]
ceil_time = [-(-d//10)*10 for d in dishes]
diff = [c - d for c, d in zip(ceil_time, dishes)]
di = diff.index(max(diff))
print(sum(ceil_time) - diff[di])

Submission status: Accepted

Solution code:
import numpy as np
import sys

input = sys.stdin.readline


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


min_x = 9
flag = False
cnt = 0

y = []

see = False
for a in x:
    if a%10 != 0:
        y.append((a//10)*10+10)
        min_x = min(a%10,min_x)
        see = True
    else:
        y.append(a)

if see:print(sum(y)-(10-min_x))
else:print(sum(y))

Submission status: Accepted

Solution code:
dish = []
amari = []
for i in range(5):
  s = int(input())
  dish.append(s)
  if s % 10 != 0:
    a = 10 - s % 10
  else:
    a = 0
  amari.append(a)

final = amari.index(max(amari))
score = 0
for i in range(5):
  if i == final:
    score += dish[final]
  else:
    if dish[i] % 10 == 0:
      score += dish[i]
    else:
      score += (dish[i] // 10 + 1) * 10
      
print(score)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = 9 - ((a - 1) % 10)
g = 9 - ((b - 1) % 10)
h = 9 - ((c - 1) % 10)
i = 9 - ((d - 1) % 10)
j = 9 - ((e - 1) % 10)
print(a + b + c + d + e + f + g + h + i + j - max(f, g, h, i, j))

Submission status: Accepted

Solution code:
import math
a=[input() for i in range(5)]
b,c=10,0
for i in range(5):
    if 0<int(a[i][-1])<b:
        b=int(a[i][-1])
        d=i
for i in range(5):
    if b!=10:
        if i==d:
            c+=int(a[i])
        else:
            if int(a[i][-1])==0:
                c+=int(a[i])
            elif int(a[i])<=10:
                c+=10
            else:
                c+=(int(a[i][0:-1])+1)*10
    else:
        c+=int(a[i])
print(c)

Submission status: Accepted

Solution code:
import itertools

A = [None] * 5
for i in range(5):
    A[i] = int(input())

ans = 10000

for a in itertools.permutations(A):
    total = 0
    for t in a:
        while total % 10 != 0:
            total += 1
        total += t
    ans = min(ans, total)

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

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

l=[II(),II(),II(),II(),II()]
l2=[l[i] if l[i]%10==0 else l[i]//10*10+10 for i in range(5)]
m = 0
for i in range(5):
    m=max(m,l2[i]-l[i])
print(sum(l2)-m)

Submission status: Accepted

Solution code:
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

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

l=[II(),II(),II(),II(),II()]
t=643
P = itertools.permutations(l)
cnt=0
for p in P:
    cnt=0
    i=0
    for x in p:
        i+=1
        cnt+=x
        if cnt%10!=0 and i!=5:
            cnt=cnt+(10-(cnt%10))
    t=min(cnt,t)
print(t)

Submission status: Accepted

Solution code:
# B - Five Dishes

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

roundtime = []
difftime = []
for i in range(5):
    roundtime.append(((menu[i]+9)//10)*10)
    difftime.append(roundtime[i]-menu[i])

print(sum(roundtime)-max(difftime))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
time = 0
t1 = [a, b, c, d, e]
t2 = []

i = 0
while i <= 4:
    if t1[i]%10 != 0:
        tmp = 10-t1[i]%10
        t2.append([10 - t1[i]%10, i]) #[10に足りない分, i]
    else:
        t2.append([t1[i]%10, i]) #[0, i]
    i += 1

#10の倍数に近い順にソート
t3 = sorted(t2)


for i in range(4):
    if t3[i][0] == 0:
        time += t1[t3[i][1]]
    else:
        time += t1[t3[i][1]] + t3[i][0]

time += t1[t3[-1][1]]

print(time)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
ans = 0
plus = 0
while plus < a:
    plus += 10
ans += plus

plus = 0
while plus < b:
    plus += 10
ans += plus

plus = 0
while plus < c:
    plus += 10
ans += plus

plus = 0
while plus < d:
    plus += 10
ans += plus

plus = 0
while plus < e:
    plus += 10
ans += plus

minus = [int(str(a)[-1]), int(str(b)[-1]), int(str(c)[-1]), int(str(d)[-1]), int(str(e)[-1])]
minus.sort()
for i in minus:
    if i !=0:
        ans -= 10-i
        break
print(ans)

Submission status: Accepted

Solution code:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
t = (a+9)//10*10+(b+9)//10*10+(c+9)//10*10+(d+9)//10*10+(e+9)//10*10
if a%10 == 0:
    aa = 10
else:
    aa = a%10
if b%10 == 0:
    bb = 10
else:
    bb = b%10
if c%10 == 0:
    cc = 10
else:
    cc = c%10
if d%10 == 0:
    dd = 10
else:
    dd = d%10
if e%10 == 0:
    ee = 10
else:
    ee = e%10
m = min(aa,min(bb,min(cc,min(dd,ee))))
print(t+m-10)

Submission status: Accepted

Solution code:
import math
A = [int(input()) for _ in range(5)]
B = 10
ans = 0
for i in range(5):
  if 0 < A[i] % 10 < B:
    B = A[i] % 10
    ans = -10+B
for j in A:
  ans += math.ceil(j/10)*10
print(ans)

Submission status: Accepted

Solution code:
foods = [int(input()) for i in range(5)]
kiriage = [-(-i//10)*10 for i in foods]
amari = [-(-i//10)*10-i for i in foods]
print(sum(kiriage) - max(amari))

Submission status: Accepted

Solution code:
foods = [int(input()) for i in range(5)]
amari = [i % 10 for i in foods]
kiriage = [-(-i//10) for i in foods]
min_amari = 10
for i in amari:
    if 1 <= i < min_amari:
        min_amari = i
print(sum(kiriage) * 10 - (10 - (10 if max(amari) == 0 else min_amari)))

Submission status: Accepted

Solution code:
from itertools import permutations
foods = [int(input()) for i in range(5)]
ans = 1230
for i in permutations(foods):
    tmp = 0
    for j in range(4):
        tmp += -(-i[j] // 10)
    tmp *= 10
    tmp += i[4]
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
S=[int(input()) for _ in range(5)]
T=[]
for i in range(5):
    T.append((10-S[i])%10)
print(sum(S)+sum(T)-max(T))

Submission status: Accepted

Solution code:
a = [int(input()) for _ in range(5)]
d = [[x, 10-x%10 if x%10!=0 else 0] for x in a]
d.sort(key=lambda x: x[1])
sumt=0
for i in range(5):
    sumt+=d[i][0]+d[i][1] if i<4 else d[i][0]
print(sumt)

Submission status: Accepted

Solution code:
res = 0
frac = 10
for i in range(5):
  a = int(input())
  if a % 10 != 0:
    frac = min(frac, a % 10)
  res += -(-a // 10) *10
print(res + frac - 10)

Submission status: Accepted

Solution code:
import math
lst = []
for i in range(5):
  lst.append(int(input()))
minu = 9
temp = 0
count = 0
for j in range(5):
  if int(str(lst[j])[-1]) < minu and int(str(lst[j])[-1]) > 0:
    minu = int(str(lst[j])[-1])
    temp = lst[j]
    count += 1
if count > 0:
  lst.remove(temp)
else:
  temp = lst[0]
  del lst[0]
time = 0
for k in range(4):
  kari = math.ceil(int(lst[k])/10)
  time += int(kari * 10)
time += temp
print(time)

Submission status: Accepted

Solution code:
l = list()
mod = list()

for a in range(0, 5):
    num = int(input())
    l.append(num)
    mod.append(num % 10)

sm = 0

for a in range(0, 5):
    if 0 in mod:
        indx = mod.index(0)
        mod.pop(indx)
        sm += l.pop(indx)
    else:
        indx = mod.index(max(mod))
        mod.pop(indx)
        sm += l.pop(indx)

    while 1:
        if a == 4:
            break
        if sm % 10 == 0:
            break
        else:
            sm += 1


print(sm)

Submission status: Accepted

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

i = list()
b = 0
for a in aaa:
  n = 0
  n = 10 - int(str(a)[-1])
  if n % 10 != 0:i.append(n)
    
if len(i) == 0:
  h = 0
else:
  h = max(i)
print(sum(aaa) + sum(i) - h)

Submission status: Accepted

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

d = 10
ans = 0
if A % 10 == 0:
    ans += A
else:
    ans += (A//10+1)*10
    d = min(A - A//10*10, d)

if B % 10 == 0:
    ans += B
else:
    ans += (B//10+1)*10
    d = min(B - B//10*10, d)

if C % 10 == 0:
    ans += C
else:
    ans += (C//10+1)*10
    d = min(C - C//10*10, d)

if D % 10 == 0:
    ans += D
else:
    ans += (D//10+1)*10
    d = min(D - D//10*10, d)
    
if E % 10 == 0:
    ans += E
else:
    ans += (E//10+1)*10
    d = min(E - E//10*10, d)

if d != 10:
    ans -= 10 - d
    
print(ans)

Submission status: Accepted

Solution code:
import itertools
s = [input() for i in range(5)]
listS = list(itertools.permutations(s))
#順列で全探索
Min = float("inf")
time = 0
for i in range(120):
    time = 0
    for j in range(5):
        time += int(listS[i][j])
        if(j != 4):
            while(time % 10 != 0):
                time += 1
    if(time < Min):
        Min = time

print(Min)

Submission status: Accepted

Solution code:
import itertools
l=[int(input()) for _ in range(5)]
l=list(itertools.permutations(l))
ans=[0]*120
for i in range(120):
  for k in range(4):
    ans[i]=ans[i]+((-1)*l[i][k]//10)*(-10)
  ans[i]+=l[i][4]
print(min(ans))

Submission status: Accepted

Solution code:
ret=0
m=10
for _ in range(5):
  y=int(input())
  ret+=(y+9)//10*10
  if y%10!=0:
    m=min(m,y%10)
print(ret-(10-m))

Submission status: Accepted

Solution code:
a=[int(input()) for i in range(5)]
b=10
c=0
for i in a:
    if str(i)[-1]!="0":
        b=min(b,int(str(i)[-1]))
        c+=10-int(str(i)[-1])
print(sum(a)-10+b+c)

Submission status: Accepted

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

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

ans = float('inf')
for i in range(5):
    t = dish[i]
    for j in range(5):
        if i == j:
            continue
        if dish[j] % 10 == 0:
            t += dish[j]
        else:
            t += 10 * (dish[j] // 10 + 1)
    ans = min(ans, t)
print(ans)

Submission status: Accepted

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

if lst == 10:
    print(ans)
else:
    print(ans - (10 - lst))

Submission status: Accepted

Solution code:
x=[int(input()) for _ in range(5)]
r=list(map(lambda a: a%10,x))
min = min(list(filter(lambda x: x>0, r))+[10])
ans=0
for i in range(5):
    ans+=-(-x[i]//10)*10
ans+= min-10
print(ans)

Submission status: Accepted

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

P = []
for i, v in enumerate(L):
    if (v % 10 == 0):
        P.append((0, i))
    else:
        P.append((10 - (v % 10), i))

P.sort()
count = 0
for i, v in enumerate(P):
    if (i == len(P) - 1):
        break
    if (v[0] == 0):
        count += L[v[1]]
    else:
        count += L[v[1]] + v[0]
print(count + L[P[-1][1]])

Submission status: Accepted

Solution code:

a = [int(input()) for _ in range(5)]
b = []
for i in range(len(a)):
    if a[i] % 10 == 0:
        b.append(0)
    else:
        b.append(10 - (a[i] % 10))
c = b.index(max(b))

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    a = [int(input()) for _ in range(5)]
    res = 10000000
    for i in permutations(a, 5):
        b = 0
        for j in range(4):
            b += i[j]
            if b%10:
                b = (b//10+1)*10
        res = min(res, b+i[-1])
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

l = [INT() for _ in range(5)]
m = 0
n = [0]

for i in range(5):
	m += -(-l[i]//10)
	if l[i]%10 != 0:
		n.append(10-l[i]%10)

print(10*m - max(n))

Submission status: Accepted

Solution code:
def main():
    a = [int(input()) for _ in range(5)]
    a.sort(key=lambda x: x % 10)

    ans = 0
    picked = False  # 最後に据える候補を選択済み
    for x in a:
        if (not picked) and (x % 10 != 0):
            ans += x
            picked = True
        else:
            ans += (x + 9) // 10 * 10
    print(ans)


if __name__ == '__main__':
    main()

# 最後だけ一の位を切り上げずに済む
# 1 <- 10 ... 9得
# 2 <- 10 ... 8
# ...
# 9 <- 10 ... 1
# 0 <- 0  ... 0
# 下一桁が1,2,3,...,9,0で左に来る数を最後に据えればよい

Submission status: Accepted

Solution code:
def main():
    from itertools import permutations
    a = [int(input()) for _ in range(5)]

    ans = -1
    for perm in permutations(a):
        it = iter(perm)
        t = next(it)
        for x in it:
            t += (x + 9) // 10 * 10
        if not (~ans) or t < ans:
            ans = t
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
menu = [int(input()) for i in range(5)]
time = [0]*5
last = 0
num = 0
for i in range(5):
    time[i] = math.ceil(menu[i]/10)*10
    if time[i]-menu[i]>=last:
        last = time[i]-menu[i]
        num = i
    else:
        continue
print(sum(time)-time[num]+menu[num])

Submission status: Accepted

Solution code:
A=[0]*5
B=0
A[0]=int(input())
A[1]=int(input())
A[2]=int(input())
A[3]=int(input())
A[4]=int(input())
count=0
for i in range(0,5):
    if A[i]%10==0:
        count+=A[i]
    else:
        if B==0:
            B=A[i]
        elif B%10>=A[i]%10:
            count+=((B+10)-(B%10))
            B=A[i]
        else:
            count+=((A[i]+10)-(A[i]%10))
print(count+B)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
aa=(a+9)//10*10
bb=(b+9)//10*10
cc=(c+9)//10*10
dd=(d+9)//10*10
ee=(e+9)//10*10
print(aa+bb+cc+dd+ee-max(aa-a,bb-b,cc-c,dd-d,ee-e))

Submission status: Accepted

Solution code:
ans = 0
def ceil(a, b):
   return a // b + (a % b > 0)
big = 0
for _ in range(5):
    a = int(input())
    ans += ceil(a, 10) * 10
    if a % 10 != 0:
        big = max(big, 10-(a%10))

print(ans-big)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a = [inp() for _ in range(5)]
mi = 10
ind = -1
for i,t in enumerate(a):
    tmp = int(str(t)[-1])
    if tmp < mi and tmp:
        mi = tmp
        ind = i
a[ind], a[4] = a[4], a[ind]
now = 0
for i in a:
    if now%10:
        now += 10-now%10
    now += i
print(now)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L = [INT() for i in range(5)]
A = []
for l in L:
    A.append(ceil(l * 0.1) * 10)
# print(A)

ans = INF
for i in range(5):
    tmp = 0
    for j in range(5):
        if i == j:
            tmp += L[j]
        else:
            tmp += A[j]
    ans = min(tmp, ans)
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())

L=[A,B,C,D,E]
X=[]
for l in L:
    res=ceil(l*0.1)*10
    #print(res)
    X.append([res,l,res-l])
X=sorted(X, key=lambda x: x[2], reverse=True)
ans=0
for i,x in enumerate(X):
    res,l=x[0],x[1]
    if i==0:
        ans+=l
    else:
        ans+=res

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

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

# 愚直に全部回すか
# ％10が一番小さいの料理が一番最後
A = list(map(int, open(0).read().split()))
ans = 0
B = []
for a in A:
    ans += (a - 1) // 10 + 1
    B.append(10 - a % 10 if a % 10 != 0 else 0)

print(ans * 10 - max(B))

Submission status: Accepted

Solution code:
p = [int(input())for i in range(5)]
perm  =[0]*5
used = [0]*5
nums = []
def dfs(now):
    if now == 5:
        nums.append([perm[i]for i in range(5)])
        
        
        return
    for i in range(5):
        if used[i]:continue
        used[i] = 1
        perm[now] = i
        dfs(now+1)
        used[i] = 0
dfs(0)

ans = 10**19
for l in nums:
    time = 0
    
    for i in range(5):
        
        time +=p[l[i]]
        if i == 4:break
        
        for i in range(10):
            
            if time%10 == 0:
                break
            time +=1
    ans = min(ans,time)
print(ans)

Submission status: Accepted

Solution code:
ans = 0
y = []
z = []
for i in range(5):
    X = int(input())
    if X % 10 != 0:
        y.append(10 - X%10)
    z.append(X)

if len(y)>0:
    print(sum(z) + sum(y) - max(y))
else:
    print(sum(z))

Submission status: Accepted

Solution code:
A = []
ans = 0
for _ in range(5):
  a = int(input())
  if a % 10 == 0: ans += a
  else: A.append(a)
if len(A) > 0:
  A.sort(key = lambda x:x%10)
  ans += A[0]
  for a in A[1:]:
    ans += a + 10 - a%10
print(ans)

Submission status: Accepted

Solution code:
from math import ceil
a=[int(input())for i in range(5)]
m=1000
idx=100
for i,aa in enumerate(a):
  t=str(aa)
  t=t[-1]
  t=int(t)
  if 0<t<=m:
    m=t
    idx=i
ans=0
for i,aa in enumerate(a):
  if i==idx:
    ans+=aa
    continue
  ans+=ceil(aa/10)*10
print(ans)



# for i in range(5):
#   t=int(input())
#   q,r=divmod(t,10)
#   if r>0:
#     q+=1

Submission status: Accepted

Solution code:
dishes = []
for i in range(5):
    time = int(input())
    diff = (10 - time % 10) % 10
    dishes.append([time, diff])
dishes = sorted(dishes, key=lambda x: x[1])
ans = 0
for i in range(4):
    time = dishes[i][0]
    ans += time + dishes[i][1]
ans += dishes[-1][0]
print(ans)

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    l = [int(input()) for _ in range(5)]
    r = INF
    for i in range(5):
        if l[i] % 10 == 0:
            continue
        r = min(r, l[i] % 10)
    if r != INF:
        ans = sum([math.ceil(i / 10) * 10 for i in l]) - 10 + r
    else:
        ans = sum(l)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a = [int(input()) for _ in range(5)]
mn = 100
for i in range(5):
    amari = a[i]%10
    if a[i]%10==0:
        amari = 10
        
    if mn>amari:
        mn = amari
        mn1 = i
        
ans = 0
for i in range(5):
    if i==mn1:
        continue
    else:
        if a[i]%10==0:
            ans1 = a[i]//10
        else:
            ans1 = (a[i]//10)+1
        ans += (ans1)*10
ans += a[mn1]
print(ans)