Problem Solving report codeforces 581C developing Skills
Description
Petya loves computer games. Finally a game that he's been waiting for so long came out!
The main character of this game have n different skills, each of the which are characterized by a integer ai from 0 to 100. The higher the number AI is, the higher is the i-th skill of the character. The total rating of the character are calculated as the sum of the values of for all I from 1 to N. The expression⌊x⌋denotes the result of rounding the number Xdown to the nearest integer.
At the beginning of the game Petya got K improvement units as a bonus so he can use for increase the skills of his Charac ter and his 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 the 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≤107)-the number of skills of th e character and the number of units of improvements at Petya ' 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 Input Input
2 4
7 9
Output
2
Input
3 8
17) 15 19
Output
5
Input
2 2
99 100
Output
20
Hint
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 lfloorfrac{100}{10} RF Loor + lfloorfrac{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.
Source codeforces Round #322 (Div. 2)
Main topic: There are n skills, each skill has an initial proficiency ([1,100]). There are now K skill points, each skill point can give a skill +1 proficiency (can be repeated to the same skill plus proficiency, but not more than 100 proficiency). The final score is the sum of 10 of the proficiency of each skill divisible. That is ∑ ((int) (SKILL/10)). Q. What is the maximum value of the final score?
Analysis: A super-water problem ... Still do too urgent, and deducted points. Cry. Before you do it, it is clear that greed should be greedy first to the mantissa is 9 plus proficiency, and then to the mantissa of 8 ... After this round, everyone ended with 0. At this point, if K is still remaining, then you can add a few 10. (Note that it may not be used, and all skills are 100).
As a result, all the proficiency of the greedy level to 0 end, and then start scanning from 1~n, see how many more 10 can be added, then get the final answer.
On the code:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace
Std
const int MAXN = 1e5 + 10;
struct Node {int num;
int dig;
BOOL operator< (const node& RHS) Const {if (dig = =) return false;
if (Rhs.dig = =) return true;
return dig > Rhs.dig;
}
};
Node NODE[MAXN];
int main () {int n, K;
while (scanf ("%d%d", &n, &k) = = 2) {memset (node, 0, sizeof node);
int ans = 0;
for (int i = 1; I <= n; i++) {scanf ("%d", &node[i].num);
Node[i].dig = (Node[i].num = = 10:node[i].num% 10);
Ans + = NODE[I].NUM/10;
} Sort (node + 1, node + n + 1);
for (int i = 1; node[i].dig!=10&&i<=n; i++) {k-= (10-node[i].dig);
if (k < 0) goto here;
ans++;
Node[i].num + = (10-node[i].dig);
Node[i].dig = (Node[i].num = = 10:node[i].num% 10);
} for (int i = 1; I <= n; i++) {k-= 100-node[i].num; if (k < 0) {ans + =(k + 100-node[i].num)/10;
Break
} ans + = (100-node[i].num)/10;
Node[i].num = 100;
} here:;
printf ("%d\n", ans);
} return 0; }