C. Developing Skills

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/581/problem/C

Description

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 Input

2 4
7 9

Sample Output

2

HINT

题意

有一个人有n个技能,有k个技能点

每个技能最高10级,每点十个技能点算一级

然后问你最后级数之和最高为多少

题解:

优先队列贪心就好了

优先加离10进的数

代码:

//qscqesze
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 1205000
#define mod 1000000007
#define eps 1e-9
#define e exp(1.0)
#define PI acos(-1)
#define lowbit(x) (x)&(-x)
const double EP = 1E- ;
int Num;
//const int inf=0x7fffffff;
const ll inf=;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************* struct node
{
int x;
bool operator<(const node& other) const
{
if((x%)==(other.x%))return x>other.x;
return (x%)<(other.x%);
}
}; priority_queue<node> Q;
int main()
{
int n=read(),k=read();
for(int i=;i<n;i++)
{
int x=read();
Q.push(node{x});
}
while(k)
{
node now = Q.top();
if(now.x==)break;
int p = min(-now.x%,k);
now.x+=p;
k-=p;
Q.pop();
Q.push(now);
}
int ans = ;
for(int i=;i<n;i++)
{
node t = Q.top();
ans += t.x/;
Q.pop();
}
cout<<ans<<endl;
}

Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列的更多相关文章

  1. Codeforces Round #322 (Div. 2)

    水 A - Vasya the Hipster /************************************************ * Author :Running_Time * C ...

  2. Codeforces Round #222 (Div. 1) D. Developing Game 扫描线

    D. Developing Game 题目连接: http://www.codeforces.com/contest/377/problem/D Description Pavel is going ...

  3. Codeforces Round #222 (Div. 1) D. Developing Game 线段树有效区间合并

    D. Developing Game   Pavel is going to make a game of his dream. However, he knows that he can't mak ...

  4. Codeforces Round #322 (Div. 2) D. Three Logos 暴力

    D. Three Logos Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/problem ...

  5. Codeforces Round #322 (Div. 2) B. Luxurious Houses 水题

    B. Luxurious Houses Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/pr ...

  6. Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题

    A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  7. Codeforces Round #222 (Div. 1) D. Developing Game

    D - Developing Game 思路:我们先枚举左边界,把合法的都扣出来,那么对于这些合法的来说值有v 和 r两维了,把v, r看成线段的两端, 问题就变成了,最多能选多少线段 使得不存在这样 ...

  8. Codeforces Round #322 (Div. 2) —— F. Zublicanes and Mumocrates

    It's election time in Berland. The favorites are of course parties of zublicanes and mumocrates. The ...

  9. Codeforces Round #322 (Div. 2) E F

    E. Kojiro and Furrari 题意说的是 在一条直线上 有n个加油站, 每加一单位体积的汽油 可以走1km 然后每个加油站只有一种类型的汽油,汽油的种类有3种 求从起点出发到达终点要求使 ...

随机推荐

  1. 新建并保存一个空的Excel

    测试用的 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; ...

  2. UVa 10900 (连续概率、递推) So you want to be a 2n-aire?

    题意: 初始奖金为1块钱,有n个问题,连续回答对i个问题后,奖金变为2i元. 回答对每道题的概率在t~1之间均匀分布. 听到问题后有两个选择: 放弃回答,拿走已得到的奖金 回答问题: 如果回答正确,奖 ...

  3. 打造自己的reset.css

    http://shawphy.com/2009/03/my-own-reset-css.html 最近我对此观点有所新的看法,可以查看<真的还需要reset.css么?> 0,引言 每每有 ...

  4. Azure HDInsight HBase DR解决方案

    Sun wei  Sat, Feb 28 2015 3:07 AM Apache HBase是目前非常流行的NoSQL数据库,通过HDFS+Zookeep+Master+Region Server的架 ...

  5. 学习面试题Day08

    1.TCP/IP协议的理解.     TCP/IP定义了电子设备(如计算机)连入因特网的标准,以及数据如何在它们之间传输的标准.它既是互联网中的基本通信语言或协议,也是局域网的通信协议.     TC ...

  6. Entity Framework中的Migration问题

    1.自从用上了Entity Framework(简称EF),妈妈再也不用担心我要写那么复杂的SQL语句了! 这是微软新一代的ORM工具,它能够将数据库的表中的记录映射成为程序中的一个对象,当然也能够将 ...

  7. Android中全屏或者取消标题栏

    先介绍去掉标题栏的方法: 第一种:也一般入门的时候经常使用的一种方法 requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏 注意这句一定要写在se ...

  8. LINQ之路系列

    Life a Poem http://www.cnblogs.com/lifepoem/archive/2011/11/22/2258830.html

  9. 用slf4j+logback实现多功能日志解决方案 --- 转

    大家都知道,slf4j是原来log4j的作者写的一个新的日志组件,意思是简单日志门面接口,可以跟其他日志组件配合使用,常用的配合是slf4j+logback,无论从功能上还是从性能上都较之log4j有 ...

  10. (二)NUnit单元测试心得

    现在接着上次说到的内容,如何在项目中进行单元测试.由于做了一些调整,我上次发的内容,我这次也会重新发一次,请认真看看. 一.软件开发过程中存在的问题(没有使用单元测试的情况下) 难于定位bug的位置 ...