Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列
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进的数
@)1%KBO0HM418$J94$1R.jpg)
代码:
//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 优先队列的更多相关文章
- Codeforces Round #322 (Div. 2)
水 A - Vasya the Hipster /************************************************ * Author :Running_Time * C ...
- Codeforces Round #222 (Div. 1) D. Developing Game 扫描线
D. Developing Game 题目连接: http://www.codeforces.com/contest/377/problem/D Description Pavel is going ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #222 (Div. 1) D. Developing Game
D - Developing Game 思路:我们先枚举左边界,把合法的都扣出来,那么对于这些合法的来说值有v 和 r两维了,把v, r看成线段的两端, 问题就变成了,最多能选多少线段 使得不存在这样 ...
- 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 ...
- Codeforces Round #322 (Div. 2) E F
E. Kojiro and Furrari 题意说的是 在一条直线上 有n个加油站, 每加一单位体积的汽油 可以走1km 然后每个加油站只有一种类型的汽油,汽油的种类有3种 求从起点出发到达终点要求使 ...
随机推荐
- js不能执行,IE处理方法
一.如果你的ie不能打开js脚本(连系统里所有的js文件都不运行,网页上的js广告或好多页面都显示不了),请按一下步骤进行排查与解决: 1.查看是否IE的安全里面禁止了JS的运行: 将工具=>i ...
- UVa 11054 Wine trading in Gergovia
题意: 直线上有n个等距的酒庄,每个酒庄对酒的需求量为ai(正数说明需要买酒,负数需要卖酒),而且保证所有的酒庄供需平衡. 搬运x个单位的酒到相邻的酒庄需要x个劳动力,求要使所有酒庄供需平衡最少需要多 ...
- QTP检查点和参数化_百度一下
一.脚本编辑检查点: Browser("百度知道 - 全球最大中文互动问答平台").Page("百度知道 - 全球最大中文互动问答平台").WebEdit(&q ...
- 黑盒测试用例设计方法&理论结合实际 -> 因果图法
一. 概念 因果图法是一种利用图解法分析输入的各种组合情况,从而设计测试用例的方法,它适合于检查程序输入条件的各种组合情况 二. 因果图法的应用 等价类划分法和边界值分析方法都是着重考虑输入条件,但没 ...
- SSH proxy
# for Linux ssh nobody@guoliangwu.com -P 22 -C -N -D 127.0.0.1:6500 # for windows(PuTTY) plink nobod ...
- Zabbix探索:网络设备监控3
这两天主要是建立Cisco和H3C的网络设备监控模板.在建立的过程中就能明显感受到两家企业的深层次的东西. Cisco设备的CPU等信息都很好找,而且有官方的SNMP Object Navigator ...
- 430的启动,I/O中断
感言:看了这一集MSP430的讲解之后,我才知道msp430真的和arm7没什么区别了,可能在某些功能上要比arm7要优秀 1:430的系统复位和初始化初始化 430的系统复位有两个来源 1:POR上 ...
- viedeo
http://download.farsight.com.cn/download/Android.htm
- oracle spfile和pfile文件
pfile(Parameter File)从oracle8i开始使用,在oracle9i中也可以用.它以文本文件的形式存在,可以用vi等编辑器对 其中数据库参数进行修改.文件格式为initSID.or ...
- 【转载】shell中的特殊变量$
shell中的特殊变量:变量名含义$0shell或shell脚本的名字$*以一对双引号给出参数列表$@将各个参数分别加双引号返回$#参数的个数$_代表上一个命令的最后一个参数$$代表所在命令的PID$ ...