C. Developing Skills
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 char Acterized by the Integer a I from 0 to 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 for all i from 1 to N . The Expression ⌊&NBSP; x ⌋ denotes The result of rounding the number < Span class= "Tex-span" > x down to the nearest integer.
At the beginning of the game Petya got K Improvement units as a bonus so he can use to increase the skills Of his character and he total rating. One improvement unit can increase any skill of the Petya ' s character by exactly one. For example, if a4 = $, 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's permissible that some of the units would remain unused.
Your task is to determine the optimal, the using the improvement units so as to maximize the overall rating of the Chara Cter. It is not a necessary to use all the improvement units.
Input
The first line of the input contains the positive integers n and k (1≤ n ≤105 , 0≤ k ≤10 7)-the number of skills of the character and the number of units of improvements atPetya ' s Disposal.
The second line of the input contains a sequence of n integers ai (0 ≤ ai ≤100), where ai 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.
Sample Test (s) 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 have to improve the first skill to the spending 3 improvement units, and the second skill to ten, by spending one IM Provement Unit. Thus, Petya spends all he 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 are to improve the first skill to (by spending 3 improvement units) an D to improve the third skill to 1 improvement units). Thus, Petya is left with 4 improvement units and he'll be able to increase the second skill to + (which does not change The overall rating, so Petya does not necessarily has to do it). Therefore, the highest possible total rating in this example is.
In the third test case the optimal strategy for Petya are to increase the first skill to the spending 1 improvement unit . Thereafter, both skills of the character would be equal to, so Petya would not be able to spend the remaining improvemen T unit. So the answer are equal to.
1#include <cstdio>2#include <cmath>3#include <queue>4#include <algorithm>5 using namespacestd;6 7 structnode8 {9 intscore;Ten intCost ; One BOOL operator< (ConstNode tmp)Const A { - if(cost==tmp.cost) - returnScore>Tmp.score; the returnCost>Tmp.cost; - } - }; - + intMain () - { + intn,k; A while(SCANF ("%d%d", &n,&k)! =EOF) at { - intsum=0; -Priority_queue<node>Q; - for(intI=0; i<n;i++) - { - inttmp; in node E; -scanf"%d",&tmp); toe.score=tmp/Ten; +E.cost= ((int) ((tmp+Ten)*1.0/Ten))*Ten-tmp; - Q.push (e); the } * while(1) $ {Panax NotoginsengNode e=q.top (); - if(k>=e.cost&&e.score<Ten) the { + Q.pop (); Ak-=E.cost; theQ.push (node) {e.score+1,Ten}); + } - Else Break; $ } $ while(!q.empty ()) - { -sum+=Q.top (). score; the Q.pop (); - }Wuyiprintf"%d\n", sum); the } - return 0; Wu}
Codeforces 581C Developing Skills