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

ans = 0
for i in [a, b, c, d, e]:
    ans += i//10*10 + (i%10>0)*10

for i in range(1, 10):
    for j in [a, b, c, d, e]:        
        if str(j)[-1] == str(i):
            ans += i - 10
            print(ans)
            exit()
print(ans)

Submission status: Accepted

Solution code:
a=[int(input()) for _ in range(5)]
import math
b=[math.ceil(i/10)*10-i for i in a]
print(sum(a)+sum(b)-max(b))

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

L = list(map(int, read().decode("utf-8").split()))

last_ = L[0] % 10
last_index = 0
for i, t in enumerate(L):
    if 0 < t % 10 < last_:
        last_ = t % 10
        last_index = i

ans = 0
for i, t in enumerate(L):
    if i != last_index:
        ans += t
        if t % 10:
            ans += 10 - (t % 10)
ans += L[last_index]
print(ans)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

L = list(map(int, read().decode("utf-8").split()))

import itertools
p = itertools.permutations(L, 5)
ans = INF
for dishes in p:
    tmp_ans = 0
    for i, d in enumerate(dishes):
        tmp_ans += d
        rest = 10 - (d % 10)
        if i != 4 and rest != 10:
            tmp_ans += rest
    ans = min(ans, tmp_ans)
print(ans)

Submission status: Accepted

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

last, min = 0, 9
for i in range(n):
    if t[i] % 10 < min:
        if t[i] % 10 == 0:
            continue
        last = i
        min = t[i] % 10

ans = 0
for i in range(n):
    if i == last:
        continue
    if t[i] % 10 == 0:
        diff = 0
    else:
        diff = 10 - t[i] % 10
    ans += t[i] + diff

ans += t[last]

print(ans)

Submission status: Accepted

Solution code:
from math import ceil

t = [int(input()) for _ in range(5)]
t.sort(key=lambda x: ((x%10)-1)%10+1)
print(t[0] + sum(map(lambda x: ceil(x/10)*10, t[1:])))

Submission status: Accepted

Solution code:
import math
nums = [int(input()) for _ in range(5)]
mn = float('inf')

for i in nums:
    if i%10!=0:
        mn = min(mn, i%10)
if mn == float('inf'):
    mn = 10

print(sum(list(map(lambda x: int(math.ceil(x/10)*10), nums)))-10+mn)

Submission status: Accepted

Solution code:
from itertools import permutations
import math
X = [int(input()) for _ in range(5)]
Time = lambda X: sum(math.ceil(X[i]/10)*10 for i in range(4))+X[-1]
print(min(Time(x) for x in permutations(X)))

Submission status: Accepted

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

lists = [a,b,c,d,e]
lists_2 = [a%10,b%10,c%10,d%10,e%10]
for i in range(4):
  if 0 in lists_2:
    lists_2.remove(0)
  else:
    pass

count = 0
counter = 0
for i in lists:
  if i%10 == 0:
    count += i
  elif i%10!= min(lists_2):
    count += ((i//10) +1)*10
  else:
    if counter == 0:
      count += i
      counter = 1
    else:
      count += ((i//10) +1)*10
print(count)

Submission status: Accepted

Solution code:
import math
L = [int(input()) for _ in range(5)]
L.sort(key=lambda x: (x-1)%10)
print(L[0]+sum(map(lambda x:math.ceil(x/10)*10, L[1:])))

Submission status: Accepted

Solution code:
from itertools import permutations

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

MIN=10**9
for p in permutations(A):
  SUM=0
  for i in range(5):
    if i < 4:
      SUM += (p[i]+10-1)//10*10
    if i == 4:
      SUM += p[i]
  if SUM < MIN:
    MIN = SUM
    
print(MIN)

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=[0]*5
a[0]=A
a[1]=B
a[2]=C
a[3]=D
a[4]=E
b=[0]*5
for x in range(5):
  if a[x]%10!=0:
    b[x]=a[x]%10
  else:
    b[x]=10
t=min(b)
ti=b.index(t)
ans=0
for i in range(5):
  if i!=ti:
    if a[i]%10!=0:
      ans+=a[i]+(10-a[i]%10)
    else:
      ans+=a[i]
ans+=a[ti]
print(ans)

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]
    c = []
    for i in range(len(l)):
        if i == 0:
            c.append(l[i])
        else:
            if c[0] % 10 > l[i] % 10 and l[i] % 10 != 0:
                c.insert(0, l[i])
            else:
                c.append(l[i])
    ans = 0
    for i in range(len(c)):
        if i == 0:
            ans += c[i]
        else:
            if c[i] % 10 != 0:
                t = c[i] % 10
                ans = ans + c[i] + (10 - t)
            else:
                ans = ans + c[i]
    print(ans)        
main()

Submission status: Accepted

Solution code:
import math
from itertools import permutations
A = [int(input()) for _ in range(5)]

ans = float("inf")
for a in permutations(A, 5):
    m = 0
    for i in a:
        m = math.ceil(m/10)*10
        m += i
    ans = min(ans, m)
print(ans)

Submission status: Accepted

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

# ★ RE:1
# in2.txt

# B - Five Dishes /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点: 200点

# 問題文
# AtCoder 料理店では、以下の 5つの料理が提供されています。ここで、「調理時間」は料理を注文してから客に届くまでの時間とします。
#     ABC 丼： 調理時間 A分
#     ARC カレー： 調理時間 B分
#     AGC パスタ： 調理時間 C分
#     APC ラーメン： 調理時間 D分
#     ATC ハンバーグ： 調理時間 E分

# また、この店には以下のような「注文のルール」があります。
#     注文は、10の倍数の時刻 (時刻 0,10,20,30,...) にしかできない。
#     一回の注文につき一つの料理しか注文できない。
#     ある料理を注文したら、それが届くまで別の注文ができない。ただし、料理が届いたちょうどの時刻には注文ができる。

# E869120 君は時刻 0に料理店に着きました。彼は 5 つの料理全てを注文します。最後の料理が届く最も早い時刻を求めてください。
# ただし、料理を注文する順番は自由であり、時刻 0に注文することも可能とであるとします。

# 制約
#     A,B,C,D,Eは 1 以上 123以下の整数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A
# B
# C
# D
# E

# 出力
# 最後の料理が届く最も早い時刻を整数で出力せよ。

# 入力例 1
# 29
# 20
# 7
# 35
# 120

# 出力例 1
# 215

# ABC 丼→ARC カレー→AGC パスタ→ATC ハンバーグ→APC ラーメン の順に注文することにすると、各料理の最も早い注文時刻・届く時刻は以下の通りになります。

#     時刻 0に ABC 丼を注文する。時刻 29に ABC 丼が届く。
#     時刻 30に ARC カレーを注文する。時刻 50に ARC カレーが届く。
#     時刻 50に AGC パスタを注文する。57に AGC パスタが届く。
#     時刻 60に ATC ハンバーグを注文する。時刻 180に ATC ハンバーグが届く。
#     時刻 180に APC ラーメンを注文する。時刻 215に APC ラーメンが届く。

# これより早く最後の料理が届くような方法は存在しません。

# 入力例 2
# 101
# 86
# 119
# 108
# 57

# 出力例 2
# 481

# AGC パスタ→ARC カレー→ATC ハンバーグ→APC ラーメン→ABC 丼の順に注文することにすると、各料理の最も早い注文時刻・届く時刻は以下の通りになります。

#     時刻 0に AGC パスタを注文する。時刻 119に AGC パスタが届く。
#     時刻 120に ARC カレーを注文する。時刻 206に ARC カレーが届く。
#     時刻 210に ATC ハンバーグを注文する。時刻 267に ATC ハンバーグが届く。
#     時刻 270に APC ラーメンを注文する。時刻 378に APC ラーメンが届く。
#     時刻 380に ABC 丼を注文する。時刻 481に ABC 丼が届く。

# これより早く最後の料理が届くような方法は存在しません。

# 入力例 3
# 123
# 123
# 123
# 123
# 123

# 出力例 3
# 643

# これが入力される最大のケースです。 


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # line = lines[0]
    # N = int(lines[0])
    # N, Q = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[1].split()))
    values = list()
    for i in range(5):
        values.append(int(lines[i]))
    # valueses = list()
    # for i in range(Q):
    #     valueses.append(list(map(int, lines[i+1].split())))

    su = 0
    amaris = list()

    for value in values:
        amari = value % 10
        if amari > 0:
            amaris.append(10-amari)

    if amaris == []:
        result = sum(values)
    else:
        result = sum(values) + sum(amaris) - max(amaris)

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['29', '20', '7', '35', '120']
        lines_export = [215]
    if pattern == 2:
        lines_input = ['101', '86', '119', '108', '57']
        lines_export = [481]
    if pattern == 3:
        lines_input = ['123', '123', '123', '123', '123']
        lines_export = [643]
    if pattern == -1:
        lines_input = ['10', '10', '10', '10', '10']
        lines_export = [50]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(5)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    if FLAG_LOG:
        log(f'lines_input=[{lines_input}]')
        log(f'lines_export=[{lines_export}]')
        log(f'lines_result=[{lines_result}]')
        if lines_result == lines_export:
            log('OK')
        else:
            log('NG')
    finished = time.time()
    duration = finished - started
    log(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 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 S(): return input()
     
def main():
    a = []
    for i in range(5):
        a.append(I())

    ans = inf
    for arr in itertools.permutations(range(5)):
        t = 0
        for j, i in enumerate(arr):
            t += a[i]
            if t % 10 != 0 and j < 4:
                t = (t // 10 + 1) * 10
        ans = min(ans, t)
    print(ans)

main()

Submission status: Accepted

Solution code:
import math
a=[]
first=[]
for i in range(5):
    temp=str(input())
    a.append(temp)
    first.append(int(temp[-1]))
nin=0
nva=9

for i in range(5):
    if first[i]!=0 and first[i]<nva:
        nin=i
        nva=first[i]

ans=0
for i in range(5):
    if i!=nin:
        temmp=int(a[i])
        temmp=math.ceil((temmp-0.5)/10)*10
        ans+=temmp
    else:
        ans+=int(a[i])
print(ans)

Submission status: Accepted

Solution code:
# B - Five Dishes
import numpy as np
n=[]
for i in range(5):
    t = int(input())
    n.append(t)
n = np.array(n)
dl = [0]
s = np.ceil(n/10)*10

if max(n%10)==0:
    print(int(np.sum(s)))
    exit()
m = [e for e in n%10 if e not in dl]
print(int(np.sum(s)-(10-min(m))))

Submission status: Accepted

Solution code:
import math
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
z = []
x = []
y = [A, B, C, D, E]
for i in range(5):
    a = math.ceil(y[i] / 10)
    a *= 10
    x.append(a)
for i in range(5):
    c = x[i] - y[i]
    z.append(c)
k = max(z)
print(sum(x) - k)

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())

X = [I() for i in range(5)]
Y = [x % 10 for x in X if x % 10 != 0]
ans = sum(10*((x-1)//10+1) for x in X)

if len(Y) == 0:
    print(ans)
else:
    print(ans-10+min(Y))

Submission status: Accepted

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

import math

suma = sum(math.ceil(aa/10)*10 for aa in a)
ans=10**10
for i in range(5):
    ans = min(ans,a[i] + suma - math.ceil(a[i]/10)*10 )
print(ans)

Submission status: Accepted

Solution code:
List = []
for i in range (5):
  List.append(int(input()))
res = 10
n = 0
calc = 0
RES = 0
for i in range(5):
  n = List[i]%10
  RES += List[i]
  if n == 0:
    pass
  else:
    res = min(n,res)
    calc += 10-n
RES = RES + calc -10 + res
print(RES)

Submission status: Accepted

Solution code:
l,s = [],0
for _ in range(5):
    l.append(int(input()))
if len(set(l))==1:
    if l[0]%10 != 0:
        s = (10-(l[0]%10))*4
    print(sum(l) + s)
else:
    a = list(i%10 for i in l)
    b = list(10-i if i%10 else 0 for i in a)
    p = b.index(max(b))
    ans = 0
    for i in range(5):
        if l[i] != l[p]:
            ans += l[i]
            ans += b[i]
    print(ans+l[p])

Submission status: Accepted

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

Submission status: Accepted

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

def roundup(n):
    return int(math.ceil(n /10)) * 10
def get_digit(number):
    return number % 10   
s = 0
m = []
li = [A, B, C, D, E]
for i in range(len(li)):
    if get_digit(li[i]) >= 1:
        m.append(get_digit(li[i]))
f = False
m.sort()        
for l in range(len(li)):
    if len(m) > 0:
        if m[0] == get_digit(li[l]) and f == False:
            s += li[l]
            f = True
        else:
            s += roundup(li[l])
            # print(roundup(li[l]))
    else:
        s =sum(li)
print(s)

Submission status: Accepted

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

ans = 10**9
for v in itertools.permutations([a,b,c,d,e],5):
    time = 0
    for i in range(4):
        time += v[i]
        amari = time % 10
        if amari != 0:
            time += 10 - amari
    time += v[4]
    ans = min(ans,time)

print(ans)

Submission status: Accepted

Solution code:
dish = [int(input()) for i in range(5)]
s = sum(dish)
l = []
l_d =[]

for i in range(5):
    if dish[i]%10 != 0:
        l.append(dish[i]%10)

for i in l:
    l_d.append(-(i-10))

print(s+sum(sorted(l_d)[:-1]))

Submission status: Accepted

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

x=10
for i in a:
  if i>0:
    x=min(x,i)
if x ==10:
  x = 0
y = a.index(x)
l = dish.pop(y)

time = [(i//10+1)*10  if i%10 != 0 else i for i in dish]

ans = sum(time) + l
print(ans)

Submission status: Accepted

Solution code:
n = [int(input()) for i in range(5)]
m = min(n, key=lambda x: (x + 9) % 10)
n.remove(m)
print(sum([(i+9)//10 * 10 for i in n]) + m)

Submission status: Accepted

Solution code:
import math

lst = []
min_1 = "129"
for i in range(5):
    s = input()
    lst.append(s)
    if s[-1] != "0" and s[-1] <= min_1[-1]:
        min_1 = s
if min_1 == "129": min_1 = lst[0]        
lst.remove(min_1)
a = list(map(lambda x:math.ceil(int(x)/10)*10,lst))
print(sum(a) + int(min_1))

Submission status: Accepted

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

lst1 = []
lst2 = []
for i in range(5):
    if T[i]%10 == 0:
        lst1.append([0,T[i]])
    else:
        lst2.append([T[i]%10,T[i]])

lst2 = sorted(lst2, reverse=True)
lst = lst1 + lst2

ans = 0
for i in range(5):
    ans += lst[i][1]
    if lst[i][0] == 0:
        pass
    else:
        ans += 10 - lst[i][0]

if lst[i][0] == 0:
    pass
else:
    ans -= 10 - lst[i][0]

print(ans)

Submission status: Accepted

Solution code:
n = [int(input()) for i in range(5)]
m = min(n, key=lambda x: (x + 9) % 10)
n.remove(m)
print(sum([(i+9)//10 * 10 for i in n]) + m)

Submission status: Accepted

Solution code:
def main():
  num = [int(input()) for i in range(5)]
  min_num=num[0]%10
  last_index=0
  ans=0
  for i in range(1,len(num)):
    if( num[i]%10 < min_num and num[i]%10!=0) or min_num==0 :
      min_num=num[i]%10
      last_index=i
  
  for i in range(0,len(num)):
    if i==last_index or num[i]%10==0:
      ans+=num[i]
    else:
      ans+=((int(num[i]/10)+1)*10)
  print(ans)

main()

Submission status: Accepted

Solution code:
l=[]
m=[]
for i in range(5):
  i = int(input())
  k = 10 - (i%10)
  l.append(i)
  if k != 10:
    m.append(k)
m.sort()
if len(m)==0:
  print(sum(l))
else:
  s = sum(m)-m[-1]
  print(sum(l)+s)

Submission status: Accepted

Solution code:
from itertools import permutations

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

ans = []
for orders in permutations(Order):
    # print(orders)
    tmp = 0
    cnt = 1
    for order in orders:
        tmp += order
        if cnt == 5:
            ans.append(tmp)
        for _ in range(11):
            if tmp % 10 == 0:
                break
            tmp += 1
        cnt += 1

print(min(ans))

Submission status: Accepted

Solution code:
A = [int(input()) for i in range(5)]
ans =643

for n in range(5):
  S = 0
  A = [A[4]]+A[:4]
  for a in A[:4]:
    S += -(-a//10)*10
  ans = min(ans,S+A[4])
  
print(ans)

Submission status: Accepted

Solution code:
from itertools import permutations
import math
menu=5
ABCDE=[int(input()) for i in range(menu)]
orders=list(permutations(ABCDE,menu))
minimum=sum(math.ceil(time/10)*10 for time in ABCDE)
for order in orders:
    total=order[0]
    for i in range(1,menu):
        total+=math.ceil(order[i]/10)*10
    minimum=min(minimum,total)
print(minimum)

Submission status: Accepted

Solution code:
from itertools import permutations
import math
menu=5
times=[int(input()) for i in range(menu)]
orders=list(permutations(times,menu))
minimum=sum(math.ceil(time/10)*10 for time in times)
for order in orders:
    total=order[0]
    for i in range(1,menu):
        total+=math.ceil(order[i]/10)*10
    minimum=min(minimum,total)
print(minimum)

Submission status: Accepted

Solution code:
*A, = map(int, open(0).read().split())
B = [(10-a%10)%10 for a in A]
print(sum(A) + sum(B) - max(B))

Submission status: Accepted

Solution code:
import math

menu = [int(input()) for i in range(5)]
remain = [l % 10 for l in menu]

if sum(remain) == 0:
    print(sum(menu))
else:
    cost = [math.ceil(l / 10) for l in menu]
    for i in range(5):
        if remain[i] == 0:
            remain[i] = 10
    print(10 * sum(cost) - 10 + remain[remain.index(min(remain))])

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
N = [A, B, C, D, E]
loss = []
for i in range(5):
  if N[i]%10 == 0:
    loss.append(10)
  else:
    loss.append(N[i]%10)
Wait = (N[loss.index(min(loss))]) 
N.remove(Wait)
for i in range(4):
  if N[i]%10 == 0:
    Wait += N[i]
  else:
    Wait += ((N[i]//10+1)*10)
print(Wait)

Submission status: Accepted

Solution code:
import numpy as np
X = []
for i in range(5):
  tmp = int(input())
  X.append(tmp)

X_remain = np.zeros(5)
for i in range(5):
  if X[i] % 10 == 0:
    X_remain[i] = 0
  else:
    X_remain[i] = 10 -(X[i] % 10)
#print(X_remain)

ans = 0
count = 0
for i in range(10):
  for j in range(5):
    if X_remain[j] == i:
      if count < 4:
        ans += X[j] + X_remain[j]
        count += 1
      else:
        ans += X[j]
print(int(ans))

Submission status: Accepted

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

ans = 0
ans += T[0]
for i in range(1,5):
  ans += T[i]
  if T[i] % 10 != 0:
    ans += 10 - T[i] % 10
print(ans)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a = [int(input()) for _ in range(5)]
    b = [(x + 9) // 10 * 10 for x in a]

    ans = INF
    for i in range(5):
        ans = min(ans,sum(b) - b[i] + a[i])

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
short = 10
ans = 0
for i in range(5):
    n = int(input())
    if short > n%10 and n%10 > 0:
        short = n%10
    ans += (n//10)*10
    if n%10 > 0:
        ans += 10
ans -= 10 if short > 0 else 0
print(ans+short)

Submission status: Accepted

Solution code:
from itertools import permutations
def main():
    a=[int(input()) for _ in range(5)]
    ans=[]
    for x in permutations(a):
        t = 0
        for y in x:
            if t % 10 != 0:
                t = (t//10 + 1) * 10
            t += y
        ans.append(t)
    print(min(ans))
            
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import itertools
from decimal import Decimal, ROUND_CEILING
array = [ int(input()) for I in range(5) ]
for I in array:
    if not ( 1 <= I <= 123 ):
        sys.exit()

min = (123 * 5) + (10 * 5)
for J in list(itertools.permutations(array)):
    time = 0
    for K in J[0:-1]:
        time += K
        time = Decimal(time).quantize(Decimal('1E1'), rounding=ROUND_CEILING)
    time += J[-1]
    if min > time: min = time
print(min)

Submission status: Accepted

Solution code:
#38
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
last = 9
time = 0
cou = 0
check = 0
#l = [[A,"A"],[B,"B"],[C,"C"],[D,"D"],[E,"E"]]
l = [A,B,C,D,E]
for i in l:
    if i%10 !=0 :
        if last%10 >= i%10:
            last = i
            check +=1
if check !=0:
    l.remove(last)
    l.append(last)
for i in range(5):
    time += l[i]
    if i == 4:
        break
    while time%10 != 0:
        time += 1
        
    
print(time)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
num = min((A-1)%10,(B-1)%10,(C-1)%10,(D-1)%10,(E-1)%10)
print((-(-A//10)*10)+(-(-B//10)*10)+(-(-C//10)*10)+(-(-D//10)*10)+(-(-E//10)*10)+num-9)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
input = lambda: sys.stdin.readline().rstrip()

def main():
    dishes = [int(input()) for _ in range(5)]
    ans = float('inf')
    for dish in itertools.permutations(dishes, 5):
        time = 0
        for i in range(5):
            time += dish[i]
            if time%10 != 0 and i < 4:
                time += 10 - time%10
        ans = min(ans, time)
    print(ans)
            
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

d_align = [math.ceil(d / 10) * 10 for d in ds]
d_mirgin = [math.ceil(d / 10) * 10 - d for d in ds]
print(sum(d_align) - max(d_mirgin))

Submission status: Accepted

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

fcn = []   
for f in fn:
  if f%10 != 0:
    fcn.append([f,f%10-10])
  else :
    fcn.append([f,0])

fcn.sort(key=lambda x: x[1],reverse=True)    

sum = 0
for i in range(len(fcn)):
  if i != len(fcn)-1:
    sum += fcn[i][0] - fcn[i][1]
  else :
    sum += fcn[i][0]
  
print(sum)

Submission status: Accepted

Solution code:
l = []
min_s = 10
check = 0

for i in range(5):
    a = int(input())
    l.append(a)
    s = int(str(a)[-1])

    if s == 0:
        s = 10
    if s < min_s:
        min_s = s
        check = i

ans = 0
for i in range(len(l)):
    if i == check:
        ans += l[i]
    else:
        if int(str(l[i])[-1]) != 0:
            ans += l[i] + (10-int(str(l[i])[-1]))
        else:
            ans += l[i]

print (ans)

Submission status: Accepted

Solution code:
import math
a = [int(input()) for _ in range(5)]
ans = 0
min0 = 10
for i in a:
    if i%10 != 0:
        i = str(i)
        ans += int(i)+10-int(i[-1])
        min0 = min(int(i[-1]), min0)
    else:
        ans += i
print(ans-10+min0)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

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

ma = 0
s = 0
for i in li:
    tmp = ((i + (10 - 1)) // 10) * 10
    s += tmp
    ma = max(ma, abs(i - tmp))

print(s - ma)

Submission status: Accepted

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

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

ans = 10 ** 10
def order(t, mr):
  global ans
  if len(mr) == 0:
    ans = min(ans, t)
    return
  
  if t % 10 != 0:
    t = t - (t % 10) + 10
  for i in range(len(mr)):
    nextt =  t + mr[i]
    nextmr = copy.deepcopy(mr)
    del nextmr[i]
    order(nextt, nextmr)
order(0, m)
print(ans)

Submission status: Accepted

Solution code:
X = []
n = 0
idx = 0
for i in range(5):
    x = int(input())
    X.append(x)
    m = (10 - x % 10) % 10
    if n < m:
        n = m
        idx = i
res = 0
for i in range(5):
    if i != idx:
        res += (10 - X[i] % 10) % 10 + X[i]
print(res + X[idx])

Submission status: Accepted

Solution code:
time=[int(input()) for _ in range(5)]
loss=[(10-(x%10))%10 for x in time]
loss.sort()
loss.pop(-1)
#print(*loss)
print(sum(time)+sum(loss))

Submission status: Accepted

Solution code:
lst = [input() for i in range(5)]
d = [int(num) for num in lst]
lst_one = [int(list(i)[-1]) for i in lst]
if lst_one.count(0) == len(lst_one):
  print(sum(d))
else:
  if lst_one.count(0) == 0:
    idx = lst_one.index(min(lst_one))
  else:
    no_zero = [i for i in lst_one if i != 0]
    m = min(no_zero)
    idx = lst_one.index(m)

  x = d[idx]
  del d[idx]

  for i in range(len(d)):
    if d[i] % 10 != 0:
      d[i] = 10*(int((d[i]/10))+1)
    else:
      continue
  print(sum(d) + x)

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=(10-(A%10))%10
b=(10-(B%10))%10
c=(10-(C%10))%10
d=(10-(D%10))%10
e=(10-(E%10))%10
M=max(a,b,c,d,e)
print(A+a+B+b+C+c+D+d+E+e-M)

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=(10-(A%10))%10
b=(10-(B%10))%10
c=(10-(C%10))%10
d=(10-(D%10))%10
e=(10-(E%10))%10
M=max(a,b,c,d,e)
print(A+a+B+b+C+c+D+d+E+e-M)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = [ii() for _ in range(5)]

sa = 0
ans = 0
for num in N:
    if not num % 10:
        ans += num
    else:
        add = (num // 10 + 1) * 10
        ans += add
        sa = max(sa, add - num)

print(ans - sa)

Submission status: Accepted

Solution code:
import math

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

time = 0
last = 0
for i in range(5):
    time += math.ceil(l[i] / 10) * 10
    if l[i] % 10 == 0:
        continue
    else:
        last = max(last, 10 - (l[i] % 10))

print(time - last)

Submission status: Accepted

Solution code:
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=A%10
b=B%10
c=C%10
d=D%10
e=E%10
result=0
if a==0:
    result+=A
else:
    result+=(A+10-a)
if b==0:
    result+=B
else:
    result+=(B+10-b)
if c==0:
    result+=C
else:
    result+=(C+10-c)
if d==0:
    result+=D
else:
    result+=(D+10-d)
if e==0:
    result+=E
else:
    result+=(E+10-e)
if a==b==c==d==e==0:
    print(result)
else:
    l=set([a,b,c,d,e])
    l.discard(0)
    print(result-(10-min(l)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
(*t, ) = map(int, open(0).read().split())
print(sum(-(-i // 10)*10 for i in t) + min(-(-i % 10) for i in t))

Submission status: Accepted

Solution code:
import math
m = [int(input()) for _ in range(5)]
ans = 0
b = 0
for i in m:
  ans+=math.ceil(i/10)*10
  if i%10!=0:
    b = max(b, 10-i%10)
print(ans-b)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

li = [ri() for _ in range(5)]
lis = [math.ceil(i/10)*10 for i in li]
ans = inf
for i in range(5):
  ans = min(sum(lis[:i])+li[i]+sum(lis[i+1:]), ans)
print(ans)