codeforces 581C Developing Skills
2015-11-23 19:58
337 查看
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 characterized by an 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 is 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 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 a4 = 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 ≤ 105, 0 ≤ k ≤ 107) — 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 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
#include<cstdio> #include<cmath> #include<queue> #include<algorithm> using namespace std; struct node { int score; int cost; bool operator < (const node tmp)const { if(cost==tmp.cost) return score>tmp.score; return cost>tmp.cost; } }; int main() { int n,k; while(scanf("%d%d",&n,&k)!=EOF) { int sum=0; priority_queue<node>q; for(int i=0;i<n;i++) { int tmp; node e; scanf("%d",&tmp); e.score=tmp/10; e.cost=((int)((tmp+10)*1.0/10))*10-tmp; q.push(e); } while(1) { node e=q.top(); if(k>=e.cost&&e.score<10) { q.pop(); k-=e.cost; q.push((node){e.score+1,10}); } else break; } while(!q.empty()) { sum+=q.top().score; q.pop(); } printf("%d\n",sum); } return 0; }
相关文章推荐
- Java问题排查常用linux命令
- 在linux系统下搭建SVN服务器
- 3d打印(5):OpenSCAD软件学习
- 维护之WIFI-2000安全策略对应
- OpenJudge_P7941 不重复地输出数
- CentOS7 关闭防火墙
- OpenJudge_P8201 河中跳房子
- Linux kernel多线程的几种实现
- Codeforces 599 A. Patrick and Shopping
- linux常用命令
- ambarella s2l11m linux device_initcall
- linux grep 命令
- Linux部分命令概括
- 淘宝的架构
- 用故事讲述淘宝网架构成长的危机与机遇
- gdb调试nginx示例
- OpenJudge_P8206 二分法求函数的零点
- linux -- patch补丁文件以及相关内容
- 大型分布式网站架构设计与实践 第一章《面向服务的体系架构(SOA)》
- linux下luasql安装