Petya loves computer games. Finally a game that he's been waiting for so long came out!

The main character of this game has n different skills, each of which is characterized by an integer a_{i} from 0 to 100. The higher the number a_{i} is, the higher is the i-th skill of the character. The total rating of the character is calculated as the sum of the values ​​of $\lfloor \frac{a_{i}}{10} \rfloor$ for all i from 1 to n. The expression ⌊ x⌋ denotes the result of rounding the number x down to the nearest integer.

At the beginning of the game Petya got k improvement units as a bonus that he can use to increase the skills of his character and his total rating. One improvement unit can increase any skill of Petya's character by exactly one. For example, if a_4 = 46, after using one imporvement unit to this skill, it becomes equal to 47. A hero's skill cannot rise higher more than 100. Thus, it is permissible that some of the units will remain unused.

Your task is to determine the optimal way of using the improvement units so as to maximize the overall rating of the character. It is not necessary to use all the improvement units.


-----Input-----

The first line of the input contains two positive integers n and k (1 ≤ n ≤ 10^5, 0 ≤ k ≤ 10^7) — the number of skills of the character and the number of units of improvements at Petya's disposal.

The second line of the input contains a sequence of n integers a_{i} (0 ≤ a_{i} ≤ 100), where a_{i} characterizes the level of the i-th skill of the character.


-----Output-----

The first line of the output should contain a single non-negative integer — the maximum total rating of the character that Petya can get using k or less improvement units.


-----Examples-----
Input
2 4
7 9

Output
2

Input
3 8
17 15 19

Output
5

Input
2 2
99 100

Output
20



-----Note-----

In the first test case the optimal strategy is as follows. Petya has to improve the first skill to 10 by spending 3 improvement units, and the second skill to 10, by spending one improvement unit. Thus, Petya spends all his improvement units and the total rating of the character becomes equal to  lfloor frac{100}{10} rfloor +  lfloor frac{100}{10} rfloor = 10 + 10 =  20.

In the second test the optimal strategy for Petya is to improve the first skill to 20 (by spending 3 improvement units) and to improve the third skill to 20 (in this case by spending 1 improvement units). Thus, Petya is left with 4 improvement units and he will be able to increase the second skill to 19 (which does not change the overall rating, so Petya does not necessarily have to do it). Therefore, the highest possible total rating in this example is $\lfloor \frac{20}{10} \rfloor + \lfloor \frac{19}{10} \rfloor + \lfloor \frac{20}{10} \rfloor = 2 + 1 + 2 = 5$.

In the third test case the optimal strategy for Petya is to increase the first skill to 100 by spending 1 improvement unit. Thereafter, both skills of the character will be equal to 100, so Petya will not be able to spend the remaining improvement unit. So the answer is equal to $\lfloor \frac{100}{10} \rfloor + \lfloor \frac{100}{10} \rfloor = 10 + 10 = 20$.

Source: codeforces | Difficulty: MEDIUM
Tags: Mathematics

Sorting

Implementation


Solutions:
(n, k) = map(int, input().split())
(m, r) = ([0] * 10, 0)
for a in map(int, input().split()):
	m[a % 10] += 1
	r += a // 10
for i in range(1, 10):
	x = min(k // i, m[10 - i])
	k -= x * i
	r += x
print(min(r + k // 10, 10 * n))


(num_skills, improvement) = map(int, input().split())
skills = list(map(int, input().split()))
skills.sort(key=lambda skill: 10 - skill % 10)
for (i, skill) in enumerate(skills):
	if skill == 100:
		continue
	delta = min(improvement, 10 - skill % 10)
	skills[i] += delta
	improvement -= delta
	if improvement == 0:
		break
for (i, skill) in enumerate(skills):
	delta = min(improvement, 100 - skill)
	skills[i] += delta
	improvement -= delta
	if improvement == 0:
		break
result = 0
for skill in skills:
	result += skill // 10
print(result)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
left = [0] * 11
rating = 0
for i in a:
	left[10 - i % 10] += 1
	rating += i // 10
for (i, q) in enumerate(left[1:], start=1):
	possible = min(q, k // i)
	rating += possible
	k -= possible * i
print(min(rating + k // 10, 10 * n))


(n, k) = map(int, input().split())
point = list(map(int, input().split()))
MOD = [0] * 10
if k + sum(point) >= n * 100:
	print(n * 10)
else:
	ans = 0
	for i in range(n):
		ans += point[i] // 10
		MOD[point[i] % 10] += 1
	for j in range(9, -1, -1):
		if j == 0:
			ans += k // 10
			break
		elif k // (10 - j) >= MOD[j]:
			ans += MOD[j]
			k -= (10 - j) * MOD[j]
		else:
			ans += k // (10 - j)
			break
	print(ans)


from math import *
(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
s = []
for i in range(len(l)):
	s.append([int(str(l[i])[-1]), i, l[i]])
s.sort(key=lambda s: s[0])
s = s[-1::-1]
i = 0
SUM = 0
while k > 0 and i <= n - 1:
	if k >= 10 - s[i][0] and s[i][0] != 0:
		s[i][2] = s[i][2] + (10 - s[i][0])
		k -= 10 - s[i][0]
		i += 1
	else:
		break
LL = []
for i in range(len(s)):
	LL.append(s[i][2])
LL = sorted(LL)
if k != 0:
	i = 0
	while k > 0 and i <= len(LL) - 1:
		old = LL[i]
		LL[i] = min(100, LL[i] + k)
		k -= LL[i] - old
		i += 1
for i in range(len(LL)):
	SUM += floor(LL[i] / 10)
print(SUM)


def maxRating(skills, units):
	rating = 0
	skills.sort()
	possible = 0
	for i in reversed(skills):
		if not (int(units) <= 0 or 10 - int(i[0]) > int(units) or int(i[1]) == 100):
			units = int(units) - (10 - int(i[0]))
			rating += 1
			possible += 9 - i[1] // 10
		else:
			possible += 10 - i[1] // 10
		rating += i[1] // 10
	return int(rating) + min(possible, int(units) // 10)
i = input().split(' ')
skills = list()
for e in input().split(' '):
	skills.append(tuple([int(e[-1]), int(e)]))
print(maxRating(skills, i[1]))


from copy import deepcopy
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
k1 = deepcopy(l)
ans = 0
v = 0
l = deepcopy(k1)
for i in range(n):
	l[i] = [l[i], i]
for i in range(n):
	if l[i][0] == 100:
		l[i][0] = -1
		k1[i] = -1
	else:
		l[i][0] %= 10
cur = 10 ** 9
l.sort(reverse=True)
for i in range(n):
	if l[i][0] >= 0:
		cur = 10 - l[i][0] % 10
		if k < cur:
			break
		else:
			k -= cur
			k1[l[i][1]] += cur
g = 0
for i in range(n):
	if k1[i] >= 0:
		g += 10 - k1[i] // 10
for i in range(n):
	if k1[i] >= 0:
		ans += k1[i] // 10
	else:
		ans += 10
print(ans + min(g, k // 10))


(n, k) = map(int, input().split())
d = list(map(int, input().split()))
res = 0
m = 0
d = sorted(d, key=lambda x: int(str(x)[-1]))[::-1]
x = 0
while x != len(d):
	if k > 0:
		if d[x] != 100:
			k -= 10 - d[x] % 10
			if k >= 0 and d[x] != 100:
				d[x] += 10 - d[x] % 10
				m += 100 - d[x]
	res += d[x] // 10
	x += 1
if k > 0 and k <= m:
	res += k // 10
elif m > 0 and k > 0:
	res += m // 10
print(res)


(n, k) = [int(i) for i in input().split()]
skills = [int(i) for i in input().split()]

def fornextlvl(x):
	return 10 * (1 + (x - 1) // 10) - x
left = sorted([(fornextlvl(skills[i]), i) for i in range(n)])
left.reverse()
while k > 0 and len(left):
	w = left.pop()
	if w[0] > k:
		break
	k -= w[0]
	skills[w[1]] += w[0]
for i in range(n):
	t = min(k, 100 - skills[i])
	skills[i] += t
	k -= t
	if k == 0:
		break
print(sum([i // 10 for i in skills]))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
rating = 0
di = {}
for i in range(1, 10):
	di[i] = 0
for i in a:
	rating += i // 10
	if i % 10 != 0:
		di[i % 10] += 1
for x in range(9, 0, -1):
	poss = k // (10 - x)
	ans1 = min(poss, di[x])
	rating += ans1
	k -= ans1 * (10 - x)
while k >= 10:
	rating += 1
	k -= 10
print(min(rating, 10 * n))


__author__ = 'Admin'

def f(n):
	return n % 10
ans = 0
(abinum, addnum) = map(int, input().split())
abi = list(map(int, input().split()))
abi = sorted(abi, key=f, reverse=True)
for i in range(abinum):
	if addnum >= 10 - abi[i] % 10:
		addnum -= 10 - abi[i] % 10
		abi[i] += 10 - abi[i] % 10
	else:
		break
for i in range(abinum):
	delta = min(100 - abi[i], addnum)
	abi[i] += delta
	addnum -= delta
for i in range(abinum):
	ans += abi[i] // 10
print(ans)


def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return [str(x) for x in stdin.readline().split()]

def arr_enu():
	return [[int(x) % 10, int(x)] for x in stdin.readline().split()]
from sys import stdin
from math import *
(n, k) = arr_inp(1)
(a, s) = (sorted(arr_enu(), reverse=True, key=lambda x: x[0]), 0)
for i in range(n):
	if k > 0:
		a[i][1] += min(10 - a[i][0], k)
		k -= 10 - a[i][0]
for i in range(n):
	old = a[i][1]
	a[i][1] = min(100, a[i][1] + max(k // 10, 0) * 10)
	k -= a[i][1] - old
	s += floor(a[i][1] / 10)
print(s)


(n, k) = map(int, input().split())
l_s = list(map(int, input().split()))
l_s.sort(key=lambda x: x % 10 if x != 100 else x, reverse=True)
t = 0
r = 0
index = 0
for i in l_s:
	n_i = i
	if i != 100:
		n_i += min(k, 10 - i % 10)
		k -= n_i - i
		r += 100 - n_i
	t += n_i // 10
t += min(r // 10, k // 10)
print(t)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a1 = map(str, a)
a1 = list(map(int, sorted(a1, key=lambda x: x[-1], reverse=True)))
while k > 0:
	for x in range(n):
		c = 10 - a1[x] % 10
		if c <= k:
			a1[x] += c
			k -= c
		else:
			print(min(sum([x // 10 for x in a1]), n * 10))
			quit()
print(min(sum([x // 10 for x in a1]), 10 * n))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(key=lambda x: -(x % 10))
for i in range(n):
	if a[i] % 10 == 0:
		break
	add = min(k, 10 - a[i] % 10)
	a[i] += add
	k -= add
for i in range(n):
	add = min(k, 100 - a[i])
	a[i] += add
	k -= add
print(sum((x // 10 for x in a)))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
arr = sorted(arr, key=lambda x: x % 10, reverse=1)
ans = 0
s = 0
for i in range(n):
	inc = 10 - arr[i] % 10
	if k >= inc:
		arr[i] += inc
		k -= inc
	ans += arr[i] // 10
	s += 100 - arr[i]
ans += min(s, k) // 10
print(ans)


__author__ = 'artyom'

def main():
	(n, k) = read(3)
	a = sorted(read(3), key=lambda x: x % 10, reverse=True)
	res = 0
	ex = 0
	for v in a:
		res += v // 10
		rem = 10 - v % 10
		if 0 < rem <= k:
			k -= rem
			res += 1
			ex += 100 - (v + rem)
		else:
			ex += 100 - v
	return res + min(k, ex) // 10

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
write(main())


(n, k) = map(int, input().split())
sequence = list(map(int, input().split()))
a = sorted(sequence, key=lambda x: x % 10, reverse=True)
for i in range(len(a)):
	if a[i] != 100:
		if a[i] % 10 + k >= 10:
			x = 10 - a[i] % 10
			a[i] += x
			k -= x
		else:
			a[i] += k
			k = 0
red = sum([100 - x for x in a if x != 100])
ans = sum((x // 10 for x in a))
ans += min(k // 10, red // 10)
print(ans)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
if sum(a) + k >= n * 100:
	print(n * 10)
	return
adds = []
ans = 0
for i in range(n):
	ans += a[i] // 10
	if a[i] != 100:
		adds.append(10 - a[i] % 10)
adds.sort()
for i in range(len(adds)):
	if k <= 0:
		break
	else:
		k -= adds[i]
		ans += 1
ans += k // 10
print(ans)


line1 = input().split()
line2 = input().split()
n = int(line1[0])
k = int(line1[1])
a = [int(i) for i in line2]
mydict = {}
for i in a:
	if i % 10 not in mydict.keys():
		mydict[i % 10] = [i]
	else:
		mydict[i % 10].append(i)
i_key = 9
while i_key != -1:
	if i_key in mydict.keys():
		for i in range(len(mydict[i_key])):
			if k >= 10 - i_key and mydict[i_key][i] < 100:
				mydict[i_key][i] += 10 - i_key
				k -= 10 - i_key
			else:
				break
	i_key -= 1
if k > 0:
	x = list(mydict.keys())[0]
	for key in mydict.keys():
		for i in range(len(mydict[key])):
			if mydict[key][i] < 100:
				if k < 100 - mydict[key][i]:
					mydict[key][i] += k
					k = 0
				else:
					temp = 100 - mydict[key][i]
					mydict[key][i] += temp
					k -= temp
			if k == 0:
				break
		if k == 0:
			break
sum = 0
for values in mydict.values():
	for i in values:
		sum += i // 10
print(sum)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))

def f(a):
	return a % 10
a.sort(key=f, reverse=True)
res = 0
i = 0
check = 0
while 1:
	if k >= 10 - a[i] % 10:
		k -= 10 - a[i] % 10
		a[i] += 10 - a[i] % 10
	res += a[i] // 10
	i += 1
	if res >= n * 10:
		res = n * 10
		break
	if i == n and k > 0:
		if check == k:
			break
		i = 0
		res = 0
		check = k
	elif i == n:
		break
print(res)


(n, k) = map(int, input().split())
l = [0] * 11
ans = 0
for x in input().split():
	t = int(x)
	l[10 - t % 10] += 1
	ans += t // 10
for i in range(1, 10):
	t = min(k // i, l[i])
	ans += t
	k -= t * i
t = k // 10
ans += min(t, n * 10 - ans)
print(ans)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
rem = []
ans = 0
for i in l:
	rem.append(i % 10)
	ans = ans + i // 10
rem.sort()
i = n - 1
while i >= 0 and k > 0:
	if rem[i] != 0:
		sm = 10 - rem[i]
		if k >= sm:
			k = k - sm
			rem[i] = 0
			ans = ans + 1
	i = i - 1
print(min(ans + k // 10, n * 10))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
L = [[] for i in range(0, 10)]
for i in range(0, n):
	t = a[i] % 10
	if t > 0:
		t = 10 - t
	L[t].append(a[i])
for j in range(1, 10):
	for x in range(0, len(L[j])):
		if k >= j:
			L[j][x] += j
			k -= j
if k > 0:
	for j in range(0, 10):
		for i in range(0, len(L[j])):
			while L[j][i] <= 90 and k >= 10:
				k -= 10
				L[j][i] += 10
ans = 0
for j in range(0, 10):
	for x in L[j]:
		ans += x // 10
print(ans)


import time
(n, k) = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
start = time.time()
A = sorted(A, key=lambda x: -divmod(x, 10)[1])
B = [divmod(i, 10)[1] for i in A]
i = 0
while k > 0 and i < len(A):
	if B[i] == 0:
		break
	if k + B[i] - 10 > 0:
		A[i] += 10 - B[i]
		k -= 10 - B[i]
	else:
		A[i] += k
		k = 0
	i += 1
if k > 0:
	for i in range(len(A)):
		if k > 100 - A[i]:
			k -= 100 - A[i]
			A[i] = 100
		else:
			A[i] += k
			k = 0
			break
ans = sum([divmod(i, 10)[0] for i in A])
print(ans)
finish = time.time()


(n, k) = list(map(int, input().split()))
mass = list(map(int, input().split()))
points = 0
a = []
for i in mass:
	a.append([i, 10 - i % 10])
a = sorted(a, key=lambda x: x[1])
c = 0
for i in a:
	if i[0] == 100:
		points += 10
		a.remove(i)
	elif k >= i[1]:
		k -= i[1]
		i[0] = i[0] + i[1]
		i[1] = 10
	else:
		break
for i in a:
	if k >= 100 - i[0]:
		points += 10
		k -= 100 - i[0]
	else:
		points += (i[0] + k) // 10
		k = 0
print(points)


get = lambda : map(int, input().split())
(n, k) = get()
arr = list(get())
s = sum(map(lambda x: x // 10, arr))
arr = filter(lambda x: x < 100, arr)
arr = sorted(arr, key=lambda x: 10 - x % 10)
for (i, a) in enumerate(arr):
	k -= 10 - a % 10
	if k >= 0:
		arr[i] += 10 - a % 10
		s += 1
	else:
		break
arr = list(filter(lambda x: x < 100, arr))
arr.sort()
if k > 0:
	for (i, a) in enumerate(arr):
		if k + a >= 100:
			arr[i] = 100
			k -= 100 - a
			s += (100 - a) // 10
		else:
			s += k // 10
			k = 0
			break
print(s)


import sys
(n, k) = [int(i) for i in input().split()]
skill = [[int(i) % 10, int(i)] for i in input().split()]
skill.sort(reverse=True)
ans = 0
for i in range(n):
	ans += skill[i][1] // 10
for i in range(n):
	if skill[i][1] == 100:
		continue
	toup = 10 - skill[i][0]
	if k >= toup:
		k -= toup
		ans += 1
		skill[i][1] += toup
maxadd = 0
for i in range(n):
	maxadd += (100 - skill[i][1]) // 10
ans += min(k // 10, maxadd)
print(ans)


import sys
(n, k) = map(int, sys.stdin.readline().split())
an = list(map(int, sys.stdin.readline().split()))
an.sort(key=lambda x: 9 - x % 10)
i = 0
while True:
	process = 0
	for i in range(n):
		x = 10 - an[i] % 10
		if x > k:
			break
		if an[i] != 100:
			an[i] += x
			k -= x
			process += 1
	if process == 0:
		break
ans = 0
for x in an:
	ans += x // 10
print(ans)


import math
import copy
(n, k) = [int(x) for x in input().split(' ')]
A = [int(x) for x in input().split(' ')]
B = copy.deepcopy(A)
for (i, a) in enumerate(B):
	v = B[i]
	v = v % 10
	B[i] = (v, i)
B.sort(reverse=True)
for (i, a) in enumerate(B):
	j = a[1]
	a = a[0]
	if a == 100:
		continue
	a = a % 10
	if a == 0:
		continue
	if 10 - a > k:
		break
	k -= 10 - a
	A[j] += 10 - a
score = 0
for (i, a) in enumerate(A):
	if k >= 10:
		d = 100 - A[i]
		d = min(d, k)
		d = d - d % 10
		A[i] += d
		k -= d
	score += math.floor(A[i] / 10)
print(score)


I = lambda : map(int, input().split())
(n, k) = I()
a = list(I())
l = [[10 - a[i] % 10 if a[i] % 10 != 0 else 0, i] for i in range(n)]
l.sort()
for i in range(n):
	if k >= l[i][0]:
		a[l[i][1]] += l[i][0]
		k -= l[i][0]
for i in range(n):
	if k >= 100 - a[i]:
		k -= 100 - a[i]
		a[i] = 100
	else:
		a[i] += k
		k = 0
	if k == 0:
		break
print(sum([i // 10 for i in a]))


import sys
import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
rems = []
for i in range(n):
	ans += a[i] // 10
	rem = a[i] % 10
	if rem != 0:
		rems.append(10 - rem)
		a[i] += 10 - rem
rems.sort()
for i in range(len(rems)):
	if k >= rems[i]:
		ans += 1
		k -= rems[i]
		a[i] += rems[i]
for i in range(n):
	while a[i] < 100 and k >= 10:
		a[i] += 10
		ans += 1
		k -= 10
print(ans)


(n, k) = map(int, input().split())
a = sorted(map(int, input().split()), key=lambda x: 10 - x % 10)
for i in range(n):
	if a[i] == 100:
		continue
	need = 10 - a[i] % 10
	if need > k:
		a[i] += k
		k = 0
		break
	a[i] += need
	k -= need
for i in range(n):
	if k == 0:
		break
	need = 100 - a[i]
	if need <= k:
		a[i] = 100
		k -= need
	else:
		a[i] += k
		k = 0
print(sum([v // 10 for v in a]))


(n, k) = map(int, input().split(' ')[:2])
a = list(map(int, input().split(' ')[:n]))
b = [0 for i in range(101)]
rating = 0
for i in a:
	b[i] += 1
	rating += i // 10
for last_dig in range(9, 0, -1):
	for first_dig in range(10):
		v = first_dig * 10 + last_dig
		need_for_one = 10 - last_dig
		can_use = min(b[v], k // need_for_one)
		k -= can_use * need_for_one
		b[v] -= can_use
		b[(first_dig + 1) * 10] += can_use
		rating += can_use
z = k // 10
for first_dig in range(10):
	v = first_dig * 10
	can_use = min(z, b[v])
	b[first_dig * 10] -= can_use
	b[(first_dig + 1) * 10] += can_use
	z -= can_use
	rating += can_use
print(rating)


from sys import stdin
input = stdin.readline
(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
skills = 0
remain = 0
for i in range(n):
	skills += l[i] // 10
	a = round(l[i], -1)
	if a < l[i]:
		a += 10
	if a < 100:
		remain += (100 - a) // 10
	if l[i] >= 100:
		l[i] = 0
		continue
	b = a - l[i]
	l[i] = b
spent = 0
l.sort()
for i in range(len(l)):
	if spent + l[i] <= k and l[i] != 0:
		skills += 1
		spent += l[i]
skills += min(remain, (k - spent) // 10)
print(skills)


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort(key=lambda x: x % 10, reverse=True)
i = 0
while i < n and k > 0 and (a[i] % 10 > 0):
	t = max(0, k - 10 + a[i] % 10)
	a[i] = a[i] // 10 * 10 + min(10, a[i] % 10 + k)
	k = t
	i += 1
i = 0
while i < n and k > 0:
	t = 100 - a[i]
	a[i] += min(k, t)
	k = max(0, k - t)
	i += 1
ans = 0
for i in a:
	ans += i // 10
print(ans)


import sys
input = sys.stdin.readline
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(key=lambda x: 10 - x % 10)
for idx in range(n):
	temp = 10 - a[idx] % 10
	if k < temp:
		break
	if a[idx] + temp > 100:
		continue
	a[idx] += temp
	k -= temp
a.sort()
idx = 0
while True:
	if k <= 0:
		break
	if a[idx] >= 100:
		break
	prev = a[idx]
	a[idx] = min(100, a[idx] + k)
	k -= a[idx] - prev
	idx = (idx + 1) % n
ans = 0
for i in range(n):
	ans += a[i] // 10
print(ans)


(n, k) = map(int, input().split())
x = list(map(int, input().split()))
x.sort(key=lambda x: 10 - x % 10)
a = []
ans = 0
for i in range(n):
	if x[i] == 100:
		ans += 10
		continue
	elif x[i] % 10 == 0:
		a.append(x[i])
	elif x[i] % 10 != 0:
		if k >= 10 - x[i] % 10:
			k -= 10 - x[i] % 10
			a.append(x[i] + 10 - x[i] % 10)
		else:
			ans += x[i] // 10
a.sort()
for j in range(len(a)):
	if 100 - a[j] <= k:
		k -= 100 - a[j]
		ans += 10
	else:
		ans += (a[j] + k) // 10
		k = 0
print(ans)


(n, k) = list(map(int, input().split()))
ki = [0] * 11
su = 0
for x in input().split():
	t = int(x)
	ki[10 - t % 10] += 1
	su += t // 10
for i in range(1, 10):
	t = min(k // i, ki[i])
	su += t
	k -= t * i
t = k // 10
su += min(t, n * 10 - su)
print(su)


__author__ = 'User'
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
mx = [0] * n
score = 0
for i in range(n):
	if arr[i] != 100:
		mx[i] = (10 - arr[i] % 10, i)
	else:
		mx[i] = (-1, i)
	score += arr[i] // 10
mx.sort()
i = 0
while i < n and k >= mx[i][0]:
	if mx[i][0] != -1:
		k -= mx[i][0]
		arr[mx[i][1]] += mx[i][0]
		score += 1
	i += 1
if i == n:
	i = 0
	k -= k % 10
	while k >= 10 and i < n:
		if arr[i] != 100:
			d = 100 - arr[i]
			if k >= d:
				k -= d
				score += d // 10
			else:
				score += k // 10
				k = 0
		i += 1
print(score)


(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
sum = 0
ost = [(0, 0)] * n
sot = [0] * n
sot1 = [0] * n
for i in range(n):
	sum += a[i] // 10
	ost[i] = (a[i] % 10, a[i])
ost1 = list(reversed(sorted(ost)))
for i in range(n):
	sot[i] = ost1[i][0]
	sot1[i] = ost1[i][1]
for i in range(n):
	if k - (10 - sot[i]) >= 0 and sot1[i] < 100:
		sum += 1
		k -= 10 - sot[i]
		sot1[i] += 10 - sot[i]
		sot[i] = 0
	else:
		break
pot = n * 10
bezb = pot - sum
if k // 10 > bezb:
	sum += bezb
else:
	sum += k // 10
print(sum)


(n, k) = map(int, input().split())
arr = [int(x) for x in input().split()]
arr.sort(key=lambda x: -(x % 10))
ans = 0
for i in range(n):
	x = 10 - arr[i] % 10
	if k >= x:
		if arr[i] + x <= 100:
			arr[i] += x
			k -= x
	else:
		break
for i in range(n):
	while k - 10 >= 0 and arr[i] + 10 <= 100:
		arr[i] += 10
		k -= 10
for i in range(n):
	ans += arr[i] // 10
print(ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
r = [0] * 12
for x in a:
	r[10] += x // 10
	if x != 100:
		r[11] += 9 - x // 10
		r[x % 10] += 1
for x in range(9, -1, -1):
	r[10] += min(k // (10 - x), r[x])
	k = max(0, k - (10 - x) * r[x])
print(r[10] + min(k // 10, r[11]))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
x = [0] * 15
ans = 0
for i in a:
	x[i % 10] += 1
	ans += i // 10
for i in range(9, -1, -1):
	ans += min(k // (10 - i), x[i])
	k -= min(k // (10 - i), x[i]) * (10 - i)
if ans < 10 * n:
	ans += min(10 * n - ans, k // 10)
print(min(n * 10, ans))


(n, k) = map(int, str.split(input()))
a = sorted(map(int, str.split(input())), key=lambda x: x % 10, reverse=True)
rating = 0
for i in range(n):
	delta = 10 - a[i] % 10
	if k >= delta and a[i] < 100:
		a[i] += delta
		k -= delta
	rating += a[i] // 10
for i in range(n):
	if k < 10:
		break
	while a[i] < 100 and k >= 10:
		a[i] += 10
		k -= 10
		rating += 1
print(rating)


def main():
	(n, k) = map(int, input().split())
	a = [[10 - p % 10, p] for p in map(int, input().split())]
	a.sort()
	for i in a:
		if k <= 0:
			break
		if i[0] > 0 and i[1] < 100 and (i[0] <= k):
			i[1] += i[0]
			k -= i[0]
			i[0] = 0
	k = k // 10
	s = 0
	for i in a:
		while k > 0 and i[1] <= 90:
			k -= 1
			i[1] += 10
		s += i[1] // 10
	print(s)
main()


(n, k) = map(int, input().split())
As = list(map(int, input().split()))

def solve(n, k, As):
	rems = [0] * 10
	caps = 0
	lower = 0
	for a in As:
		(m, r) = divmod(a, 10)
		rems[-r % 10] += 1
		lower += m
		if r:
			caps += 10 - (m + 1)
		else:
			caps += 10 - m
	for (i, c) in enumerate(rems[1:], 1):
		if k >= i * c:
			k -= i * c
			lower += c
		else:
			cc = k // i
			k -= cc * i
			lower += cc
			return lower
	if caps <= k // 10:
		return lower + caps
	return lower + k // 10
print(solve(n, k, As))


import math

def func(x):
	return 10 * math.ceil(x / 10) - x
(n, k) = map(int, input().split())
skills = list(map(int, input().split()))
skills_sort = sorted(skills, key=func)
rating = tens = 0
for i in skills_sort:
	p = math.ceil(i / 10)
	tens += (100 - p * 10) // 10
	t = p * 10 - i
	if k >= t:
		rating += p
		k -= t
	else:
		rating += i // 10
rating += min(tens, k // 10)
print(rating)


import sys
import math
from collections import defaultdict
MAXNUM = math.inf
MINNUM = -1 * math.inf
ASCIILOWER = 97
ASCIIUPPER = 65

def getInt():
	return int(sys.stdin.readline().rstrip())

def getInts():
	return map(int, sys.stdin.readline().rstrip().split(' '))

def getString():
	return sys.stdin.readline().rstrip()

def printOutput(ans):
	sys.stdout.write()
	pass

def score(l):
	total = 0
	for ele in l:
		total += ele // 10
	return total

def solve(n, k, levels):
	levels.sort(key=lambda x: x % 10, reverse=True)
	for (i, ele) in enumerate(levels):
		if ele == 100:
			continue
		r = 10 - ele % 10
		if r <= k:
			levels[i] += r
			k -= r
	for (i, ele) in enumerate(levels):
		if ele == 100:
			continue
		r = 100 - ele % 100
		if r <= k:
			levels[i] += r
			k -= r
		else:
			levels[i] += k
			k = 0
	return score(levels)

def readinput():
	(n, k) = getInts()
	levels = list(getInts())
	print(solve(n, k, levels))
readinput()


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
	ans += a[i] // 10
	a[i] %= 10
a.sort()
a = a[::-1]
i = 0
while i != n and a[i] != 0 and (m > 0):
	c = 10 - a[i]
	if m >= c:
		m -= c
		ans += 1
	else:
		m = 0
	i += 1
ans += m // 10
if ans < 10 * n:
	print(ans)
else:
	print(10 * n)


def cmp(a):
	return a % 10

def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort(reverse=True, key=cmp)
	for i in range(len(a)):
		if a[i] == 100:
			continue
		temp = a[i] % 10
		if 10 - temp > k or temp == 0:
			continue
		else:
			a[i] += 10 - temp
			k -= 10 - temp
	if k >= 10:
		i = 0
		while k > 0 and i < n:
			while a[i] <= 90 and k >= 10:
				a[i] += 10
				k -= 10
			i += 1
	ans = 0
	for i in range(len(a)):
		ans += a[i] // 10
	print(ans)
	return
main()


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
arr = list()
for i in range(n):
	arr.append(((10 - a[i] + a[i] // 10 * 10) % 10, a[i]))
arr.sort()
ans = 0
for i in range(n):
	if arr[i][1] >= 100 or k - arr[i][0] < 0:
		ans += arr[i][1] // 10
		continue
	k -= arr[i][0]
	ans += (arr[i][1] + arr[i][0]) // 10
t = 10 * n - ans
ans += min(k // 10, t)
print(ans)


from math import floor
(n, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
a.sort(key=lambda x: x % 10, reverse=True)
cur = 0
won = 0
full = False
while k > 0 and (not full):
	full = True
	for i in range(n):
		if a[i] != 100:
			full = False
			c = 10 - a[i] % 10
			if c > k:
				k = -1
				break
			else:
				a[i] += c
				k -= c
print(sum((floor(a[i] / 10) for i in range(n))))


def get_key(x):
	return 10 - x % 10

def main():
	[n, k] = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	a.sort(key=get_key)
	for i in range(n):
		u = get_key(a[i])
		if k < u:
			break
		elif a[i] < 100:
			k -= u
			a[i] += u
	for i in range(n):
		if k == 0:
			break
		elif k >= 100 - a[i]:
			k -= 100 - a[i]
			a[i] = 100
		else:
			a[i] += k
			k = 0
	s = 0
	for i in range(n):
		s += a[i] // 10
	print(s)
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * 11
s = 0
for i in range(n):
	b[10 - a[i] % 10] += 1
	s += a[i] // 10
for i in range(1, 10):
	m = min(b[i], k // i)
	s += m
	k -= m * i
print(min(10 * n, s + k // 10))


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
res = 0
for i in range(n):
	res += arr[i] // 10
	arr[i] = 10 - arr[i] % 10
arr.sort()
for i in arr:
	if i == 0:
		continue
	if k >= i:
		k -= i
		res += 1
print(min(n * 10, res + k // 10))


(n, k) = tuple(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(key=lambda x: x % 10, reverse=True)
s = 0
units = 0
for i in a:
	if k >= 10 - i % 10 and i < 100:
		s += 1
		k -= 10 - i % 10
		if i % 10 == 0:
			units -= 1
	s += i // 10
	units += (100 - i) // 10
if k >= 10:
	s += min(k // 10, units)
print(s)


import sys
sys.setrecursionlimit(10000)
t = 1
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	mydict = {}
	rating = 0
	for i in a:
		if i % 10 not in mydict:
			mydict[i % 10] = 0
		mydict[i % 10] += 1
		rating += i // 10
	if k >= 100 * n - rating:
		rating = 10 * n
	else:
		broke = False
		for i in range(9, 0, -1):
			if i not in mydict:
				continue
			if (10 - i) * mydict[i] >= k:
				rating += k // (10 - i)
				broke = True
				break
			else:
				rating += mydict[i]
				k -= mydict[i] * (10 - i)
		if not broke:
			rating += k // 10
	if rating > 10 * n:
		rating = 10 * n
	print(rating)


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
s = 0
a.sort(key=lambda x: x % 10)
for i in range(n - 1, -1, -1):
	if a[i] < 100:
		t = 10 - a[i] % 10
		k -= t
		if k > -1:
			a[i] += t
		else:
			break
for i in a:
	s += i // 10
k //= 10
if k != -1:
	s = min(n * 10, s + k)
print(s)


from collections import Counter
import string
import math
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
testcases = 1
for _ in range(testcases):
	(n, k) = vary(2)
	ki = [0] * 11
	su = 0
	for x in input().split():
		t = int(x)
		ki[10 - t % 10] += 1
		su += t // 10
	for i in range(1, 10):
		t = min(k // i, ki[i])
		su += t
		k -= t * i
	t = k // 10
	su += min(t, n * 10 - su)
	print(su)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
(n, k) = map(int, input().split(' '))
l = list(map(int, input().split(' ')))
l1 = []
for i in range(n):
	l2 = []
	l2.append(l[i])
	l2.append(10 - l[i] % 10)
	l1.append(l2)
l1.sort(key=lambda x: x[1])
total = 0
while k > 0:
	boo = 0
	for i in range(n):
		if l1[i][1] <= k and l1[i][0] + l1[i][1] <= 100:
			l1[i][0] += l1[i][1]
			k -= l1[i][1]
			l1[i][1] = 10
			boo = 1
		else:
			continue
	if boo == 0:
		break
for i in range(n):
	total = total + l1[i][0] // 10
print(total)


(n, k) = map(int, input().split(' '))
mas = list(map(int, input().split(' ')))
submas = [10 - i % 10 if i < 100 else 11 for i in mas]
summ = 0
for i in mas:
	summ += i // 10
submas.sort()
for i in submas:
	if k >= i and i <= 10:
		k -= i
		summ += 1
	else:
		break
if k >= 10:
	for i in range(n):
		if mas[i] < 100:
			mas[i] = mas[i] + 10 - mas[i] % 10
		if k >= 100 - mas[i]:
			summ += (100 - mas[i]) // 10
			k -= 100 - mas[i]
		else:
			summ += k // 10
			break
print(summ)


(n, k) = list(map(int, input().split()))
x = list(map(int, input().split()))

def f(a):
	return a / 10 + 1 - a / 10.0
x = sorted(x)
x = sorted(x, key=lambda a: int(a / 10) + 1 - a / 10.0)
(improved, i, flag) = (0, 0, 0)
while k > 0:
	if i == n or x[i] == 100:
		break
	if (int(x[i] / 10) + 1 - x[i] / 10.0) * 10 > k:
		x[i] += k
		k = 0
		break
	k -= (int(x[i] / 10) + 1 - x[i] / 10.0) * 10
	x[i] += (int(x[i] / 10) + 1 - x[i] / 10.0) * 10
	i += 1
i = 0
while k > 0:
	if i == n:
		break
	if x[i] + k <= 100:
		x[i] += k
		k = 0
		break
	k -= 100 - x[i]
	x[i] = 100
	i += 1
for i in range(0, n):
	improved += int(x[i] / 10)
print(improved)


(n, k) = map(int, input().split())
sum = 0
arr = list(map(int, input().split()))
for i in range(0, n):
	sum = sum + arr[i] // 10
	temp = arr[i] // 10
	arr[i] = temp * 10 + 10 - arr[i]
arr.sort()
for i in range(0, n):
	if k >= arr[i]:
		k = k - arr[i]
		sum = sum + 1
	else:
		break
sum = sum + k // 10
if sum > 10 * n:
	sum = 10 * n
print(sum)


def sort_key(n):
	return (10 - n % 10, n)

def solve(a, k):
	a.sort(key=sort_key)
	change = True
	while change:
		change = False
		for (i, v) in enumerate(a):
			if v == 100:
				continue
			need = 10 - v % 10
			if k < need:
				break
			change = True
			a[i] += need
			k -= need
	return sum((v // 10 for v in a))
assert solve([7, 9], 4) == 2
assert solve([17, 15, 19], 8) == 5
assert solve([99, 100], 2) == 20
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
print(solve(a, k))


def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [int(x) for x in (f.readline() if mode == 'file' else input()).split()]
	[n, k] = get()
	a = get()
	b = []
	s = 0
	for i in a:
		if i == 100:
			s += 10
			continue
		b.append([i % 10, i])
	b.sort()
	b.reverse()
	if len(b) > 0 and k > 0:
		for i in b:
			if k >= 10 - i[0]:
				hold = min(10 - i[0], k)
				k -= hold
				i[1] += hold
				i[0] += hold
			else:
				k = 0
				break
	if k > 0 and len(b) > 0:
		k -= k % 10
		for i in b:
			if i[1] == 100:
				continue
			if k == 0:
				break
			hold = min(100 - i[1], k)
			k -= hold
			i[1] += hold
	for i in b:
		s += i[1] // 10
	print(s)
	if mode == 'file':
		f.close()
main()


I = lambda : map(int, input().split())
(n, k) = I()
r = 0
a = []
for i in I():
	r += i // 10
	a += [i % 10]
for i in sorted(a, reverse=1):
	if i + k > 9:
		k = k - 10 + i
		r += 1
print(min(n * 10, r + k // 10))


from filecmp import cmp
from math import sqrt

def inp():
	return int(input().strip())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
ten = [0] * 11
(n, k) = invr()
ans = 0
a = inlt()
for ele in a:
	ans += ele // 10
	ten[10 - ele % 10] += 1
for i in range(1, 10):
	req = min(ten[i], k // i)
	ans += req
	k -= req * i
ans += min(10 * n - ans, k // 10)
print(ans)


import itertools
import math
(n, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort(key=lambda x: (-x - 1) % 10 + 1)
for i in range(n):
	step = (-a[i] - 1) % 10 + 1
	if step == 10:
		break
	if k - step < 0:
		break
	k -= step
	a[i] += step
add = sum((100 - x for x in a))
print(sum((x // 10 for x in a)) + min(k, add) // 10)


(n, k) = map(int, input().split())
a = [x for x in map(int, input().split()) if x != 100]
bonus = n - len(a)
n -= bonus
a.sort(key=lambda x: x % 10, reverse=True)
for i in range(n):
	if k == 0:
		break
	d = min(k, 10 - a[i] % 10)
	a[i] += d
	k -= d
print(sum((x // 10 for x in a)) + min(k, sum((100 - x for x in a))) // 10 + bonus * 10)


(n, k) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
assert len(l) == n
assert all((0 <= x <= 100 for x in l))
f = [10 - l[i] % 10 for i in range(n) if l[i] % 10]
f.sort()
cur = sum((x // 10 for x in l))
for x in f:
	if k >= x:
		cur += 1
		k -= x
print(min(cur + k // 10, 10 * n))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = []
l = 0
for i in a:
	b.append(i % 10)
	l += i // 10
b.sort(reverse=True)
for i in range(n):
	if k - (10 - b[i]) >= 0:
		l += 1
		k -= 10 - b[i]
print(min(10 * n, l + k // 10))


(n, k) = map(int, input().split())
l = [int(i) for i in input().split()]
l1 = [[10 - l[i] % 10, i, l[i]] for i in range(n)]
l1.sort()
canadd = [100 - l[i] for i in range(n)]
avlbl = sum(canadd)
avlbl = min(avlbl, k)
for i in range(n):
	if avlbl == 0:
		continue
	req = l1[i][0]
	if req == 10:
		req = 0
	ind = l1[i][1]
	curr = l1[i][2]
	if avlbl < req:
		continue
	avlbl = avlbl - req
	l[ind] = l[ind] + req
sm = 0
for i in l:
	sm = sm + i // 10
print(sm + avlbl // 10)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
p = []
for i in l:
	p.append([10 - i % 10, i])
p.sort()
for i in range(n):
	if p[i][1] < 100:
		if k > 0:
			x = k
			k = k - min(min(p[i][0], x), 100 - p[i][1])
			p[i][1] += min(min(p[i][0], x), 100 - p[i][1])
		else:
			break
for i in range(n):
	if p[i][1] < 100 and k > 0:
		x = k
		k = k - min(x, 100 - p[i][1])
		p[i][1] += min(x, 100 - p[i][1])
ans = 0
for i in p:
	ans += i[1] // 10
print(ans)


(n, k) = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True, key=lambda x: x % 10)
for (i, a) in enumerate(A):
	if k <= 0 or a % 10 == 0:
		break
	new = min(k, 10 - a % 10, 100 - a)
	A[i] += new
	k -= new
if k:
	for (i, a) in enumerate(A):
		if k <= 0:
			break
		new = min(100 - a, k)
		A[i] += new
		k -= new
ans = sum((a // 10 for a in A))
print(ans)


(n, k) = map(int, input().split())
a = []
r = 0
for v in map(int, input().split()):
	r += v // 10
	a.append(v % 10)
for i in sorted(a, reverse=True):
	if i + k > 9:
		k = k - 10 + i
		r += 1
print(min(n * 10, r + k // 10))


inp = input().split()
n = int(inp[0])
k = int(inp[1])
a = input().split()
b = []
x = 0
temp = []
for i in a:
	temp = []
	x = int(i)
	if x == 100:
		temp.append(0)
		temp.append(x)
	else:
		temp.append(10 - x % 10)
		temp.append(x)
	b.append(temp)
b.sort()
j = 0
ss = 0
c = []
for t in b:
	if t[0] == 0:
		pass
	elif t[0] <= k and k != 0:
		k -= t[0]
		t[1] += t[0]
		t[0] = 0
	c.append(t[1] // 10)
c.sort()
j = 0
k = k // 10
while j < n:
	if 10 - c[j] <= k:
		k -= 10 - c[j]
		c[j] = 10
	else:
		c[j] += k
		k = 0
	ss += c[j]
	j += 1
print(ss)


(n, s) = map(int, input().split())
L = [((100 - k) % 10, k) for k in map(int, input().split())]
L = sorted(L)
suma = 0
suma1 = 0
for k in range(n):
	s -= L[k][0]
	if s < 0:
		suma += L[k][1] // 10
	else:
		suma += (L[k][0] + L[k][1]) // 10
		suma1 += (100 - L[k][1]) // 10 * 10
if s < 0:
	print(suma)
elif s < suma1:
	print(suma + s // 10)
else:
	print(suma + suma1 // 10)


(n, k) = map(int, input().split())
L = list(map(int, input().split()))
L.sort(key=lambda x: x % 10, reverse=True)
index = 0
c = 0
while index < n:
	if k >= 10 - L[index] % 10:
		if L[index] < 100:
			k -= 10 - L[index] % 10
			L[index] += 10 - L[index] % 10
	c += L[index] // 10
	index += 1
for i in range(n):
	while k >= 10 and L[i] <= 90:
		k -= 10
		L[i] += 10
		c += 1
print(c)


def rating(lst):
	return sum([a // 10 for a in lst])
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a.sort(key=lambda x: x % 10, reverse=True)
for i in range(n):
	if a[i] >= 100:
		continue
	if k <= 0:
		break
	left = 10 - a[i] % 10
	if k >= left:
		a[i] += left
		k -= left
if k > 0:
	for i in range(n):
		if k <= 0:
			break
		left = 100 - a[i]
		a[i] += min(k, left)
		k -= left
print(rating(a))


def main():
	(n, k) = map(int, input().split())
	(res, cnt) = (0, [0] * 10)
	for a in map(int, input().split()):
		res += a // 10
		cnt[a % 10] += 1
	for (rest, x) in enumerate(cnt[:-10:-1], 1):
		if k >= x * rest:
			k -= x * rest
			res += x
		else:
			print(res + k // rest)
			return
	print(min(res + k // 10, n * 10))
main()


(N, K) = map(int, input().split())
A = list(map(int, input().split()))
B = A[:]
sum = 0
for i in range(N):
	sum += B[i] // 10
	B[i] = B[i] % 10
B.sort()
for i in range(N - 1, -1, -1):
	if K <= 0:
		break
	if B[i] == 0:
		break
	if 10 - B[i] > K:
		break
	K -= 10 - B[i]
	sum += 1
res = sum + K // 10
if res > N * 10:
	res = N * 10
print(res)


import sys

def solve():
	(n, k) = rv()
	(a,) = rl(1)
	res = 0
	count = [0] * 10
	for i in range(n):
		if a[i] < 100:
			count[10 - a[i] % 10 - 1] += 1
		res += a[i] // 10
	for i in range(10):
		while count[i] > 0 and k >= i + 1:
			res += 1
			count[i] -= 1
			k -= i + 1
	already = res * 10
	possible = n * 100
	diff = possible - already
	if diff > 0:
		actual = min(diff, k)
		res += actual // 10
	print(res)

def prt(l):
	return print(' '.join(map(str, l)))

def rs():
	return map(str, input().split())

def rv():
	return map(int, input().split())

def rl(n):
	return [list(map(int, input().split())) for _ in range(n)]
if sys.hexversion == 50594544:
	sys.stdin = open('test.txt')
solve()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
a = [[i, (10 - i % 10) % 10] for i in a]
a = sorted(a, key=lambda a: a[1])
for i in range(n):
	z = min(k, a[i][1])
	a[i][0] += z
	k -= z
	if k == 0:
		break
if k > 0:
	for i in range(n):
		temp = a[i][0]
		a[i][0] = min(100, a[i][0] + k)
		k -= a[i][0] - temp
		if k == 0:
			break
ans = 0
for i in range(n):
	ans += a[i][0] // 10
print(ans)


import itertools as it
import functools
import operator
import collections
import math
import sys
import bisect

def solve(xs, k):
	n = len(xs)
	max_possible = 10 * n
	current_level = sum((x // 10 for x in xs))
	remaining_points = sorted([(100 - x) % 10 for x in xs if x < 100 and x % 10 > 0])
	acc_points = list(it.accumulate(remaining_points))
	m = len(acc_points)
	levelups = bisect.bisect_right(acc_points, k)
	if m == 0:
		return min(max_possible, current_level + k // 10)
	elif levelups < m:
		return min(max_possible, current_level + levelups)
	else:
		rest = k - acc_points[-1]
		return min(max_possible, current_level + levelups + rest // 10)

def main():
	[n, k] = [int(i) for i in input().strip().split()]
	xs = [int(i) for i in input().strip().split()]
	assert len(xs) == n
	result = solve(xs, k)
	print(result)
main()


from sys import *
inp = lambda : stdin.readline()

def main():
	(n, k) = [int(i) for i in inp().split()]
	l = [int(i) for i in inp().split()]
	a = []
	for i in l:
		a.append([10 - (i + 10) % 10, i])
	a = sorted(a)
	for i in a:
		if i[0] <= k and i[1] != 100:
			(i[1], k, i[0]) = (i[1] + i[0], k - i[0], 0)
	a = sorted(a, key=lambda x: x[1])
	if k > 0:
		for i in a:
			t = min(100, i[1] + k)
			k -= t - i[1]
			i[1] = t
	ans = 0
	for i in a:
		ans += i[1] // 10
	print(ans)
main()


(n, k) = input().split()
(n, k) = (int(n), int(k))
a = list(map(int, input().split()))
a = sorted(a, key=lambda a: a % 10, reverse=True)
for i in range(len(a)):
	if 10 - a[i] % 10 >= k:
		a[i] = a[i] + k
		k = 0
		break
	else:
		k = k - (10 - a[i] % 10)
		a[i] = a[i] + 10 - a[i] % 10
summ = 0
for i in range(len(a)):
	if 100 - a[i] >= k:
		a[i] += k
		k = 0
	else:
		k = k - (100 - a[i])
		a[i] = 100
	summ += a[i] // 10
print(summ)


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, k) = f()
ten = [0] * 11
l = il()
ans = 0
for i in l:
	ans += i // 10
	ten[10 - i % 10] += 1
for i in range(1, 10):
	req = min(ten[i], k // i)
	ans += req
	k -= req * i
ans += min(10 * n - ans, k // 10)
print(ans)


import os
import sys
from math import *
from collections import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, k) = value()
a = array()
h = []
heapify(h)
for i in a:
	heappush(h, (10 - i % 10, i))
while k:
	(need, now) = heappop(h)
	if need > k or now == 100:
		heappush(h, (need, now))
		break
	now += need
	k -= need
	heappush(h, (10, now))
ans = 0
for (_, x) in h:
	ans += x // 10
print(ans)


import math as m

def solve():
	(n, k) = (int(i) for i in input().split())
	ai = [int(i) for i in input().split()]
	cnt = 0
	if k > 100 * len(ai) - sum(ai):
		k = 100 * len(ai) - sum(ai)
	for i in range(len(ai)):
		cnt += m.floor(ai[i] / 10)
		ai[i] = ai[i] % 10
	ai.sort(reverse=True)
	for i in range(len(ai)):
		diff = 10 - ai[i]
		if diff <= k:
			k -= diff
			cnt += 1
	cnt += m.floor(k / 10)
	return cnt
print(solve())


def main():
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	lvl = list(map(lambda x: x // 10, a))
	a = [a[i] - lvl[i] * 10 for i in range(n)]
	a.sort(reverse=True)
	res = sum(lvl)
	lvl_ups = 0
	for e in a:
		if 10 - e <= k and e != 0:
			res += 1
			k -= 10 - e
			lvl_ups += 1
		elif e != 0:
			break
	lvl_left = k // 10
	print(res + min(10 * len(lvl) - sum(lvl) - lvl_ups, lvl_left))
main()