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.

Examples
Input

Copy
2 4
7 9
Output

Copy
2
Input

Copy
3 8
17 15 19
Output

Copy
5
Input

Copy
2 2
99 100
Output

Copy
20
Note

In the first test case the optimal strategy is as follows. Petya has to improve the first skill to 10 by spending 3 improvement units, and the second skill to 10, by spending one improvement unit. Thus, Petya spends all his 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 is to improve the first skill to 20 (by spending 3 improvement units) and to improve the third skill to 20 (in this case by spending 1 improvement units). Thus, Petya is left with 4 improvement units and he will be able to increase the second skill to 19 (which does not change the overall rating, so Petya does not necessarily have to do it). Therefore, the highest possible total rating in this example is .

In the third test case the optimal strategy for Petya is to increase the first skill to 100 by spending 1 improvement unit. Thereafter, both skills of the character will be equal to 100, so Petya will not be able to spend the remaining improvement unit. So the answer is equal to .

注意一些坑点即可;

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 1000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int n, k;
int a[maxn];
struct node {
int dt;
int org;
}d[maxn];
bool cmp(node a, node b) {
return a.dt < b.dt;
}
int main() {
//ios::sync_with_stdio(0);
cin >> n >> k;
for (int i = 1; i <= n; i++)rdint(a[i]), d[i].org = a[i];
int ans = 0;
for (int i = 1; i <= n; i++) {
if (d[i].org % 10 != 0) {
int tp = (d[i].org / 10 + 1) * 10;
d[i].dt = tp - d[i].org;
}
else if (d[i].org != 0 && d[i].org % 10 == 0)d[i].dt = 0;
else if (d[i].org == 0)d[i].dt = 10;
} sort(d + 1, d + 1 + n, cmp);
int cnt = 1;
int sy = 0;
while (k > 0) {
if (cnt == 1) {
for (int i = 1; i <= n; i++) {
if (k >= d[i].dt) {
k -= d[i].dt;
d[i].org += d[i].dt;
ans += (d[i].org / 10);
if (d[i].org <= 100) {
sy += 100 - (d[i].org);
}
}
else {
ans += (d[i].org / 10);
}
}
cnt++;
if (k <= 0)break;
}
else {
ans += (min(sy, k)) / 10;
k = 0;
}
}
cout << ans << endl;
return 0;
}

CF581C Developing Skills 模拟的更多相关文章

  1. cf581C Developing Skills

    Petya loves computer games. Finally a game that he's been waiting for so long came out! The main cha ...

  2. Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列

    C. Developing Skills Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...

  3. codeforces 581C. Developing Skills 解题报告

    题目链接:http://codeforces.com/problemset/problem/581/C 题目意思:给出 n 个数:a1, a2, ..., an (0 ≤ ai ≤ 100).给出值 ...

  4. Developing Skills

    题目传送门:点击打开链接 #include <iostream> #include <cstdio> #include <cstdlib> #include < ...

  5. 【Henu ACM Round#19 C】 Developing Skills

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 优先把不是10的倍数的变成10的倍数. (优先%10比较大的数字增加 如果k还有剩余. 剩下的数字都是10的倍数了. 那么先加哪一个 ...

  6. Codeforces Round #322 (Div. 2)

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

  7. codeforces581C

    Developing Skills CodeForces - 581C 你在玩一个游戏.你操作的角色有n个技能,每个技能都有一个等级ai.现在你有k次提升技能的机会(将其中某个技能提升一个等级,可以重 ...

  8. How do I learn mathematics for machine learning?

    https://www.quora.com/How-do-I-learn-mathematics-for-machine-learning   How do I learn mathematics f ...

  9. 每日英语:A Better Way To Treat Anxiety

    Getting up the nerve to order in a coffee shop used to be difficult for 16-year-old Georgiann Steely ...

随机推荐

  1. [我的CVE][CVE-2017-15709]Apache ActiveMQ Information Leak

    问题原因: Apache ActiveMQ默认消息队列61616端口对外,61616端口使用了OpenWire协议,这个端口会暴露服务器相关信息,这些相关信息实际上是debug信息. 会返回应用名称, ...

  2. 问题:c# json解析;结果:c# 解析JSON的几种办法

    c# 解析JSON的几种办法 欲成为海洋大师,必知晓海中每一滴水的真名. 刚开始只是想找一个转换JSON数组的方法,结果在MSDN翻到一大把. 搜索过程中免不了碰到一大堆名词:WCF => Da ...

  3. intellij idea打包springboot项目

    一.可执行jar包 注意点: maven的package类型需要为jar 配置了spring-boot-mavne-plugin插件 1.1.pom.xml <?xml version=&quo ...

  4. 【264】◀▶ Windows 批处理(CMD)

    参考:Windows Commands 微软官方帮助 参考:DOS命令自学小窍门:巧用help命令 参考:bat批处理的注释语句 打开文件夹: start D:\abc 打开D盘abc文件夹 打开ex ...

  5. PL/SQL批处理语句(二)FORALL

    PL/SQL批处理语句(二)FORALL 我们知道PL/SQL程序中运行SQL语句是存在开销的,因为SQL语句是要提交给SQL引擎处理,这种在PL/SQL引擎和SQL引擎之间的控制转移叫做上下文却换, ...

  6. ActiveMQ (一) 介绍与安装

    ActiveMQ是消息中间件的一种 ActiveMQ 是Apache出品,最流行的,能力强劲的开源消息总线.ActiveMQ 是一个完全支持JMS1.1和J2EE 1.4规范的 JMS Provide ...

  7. Solr各组件之间的关系图

    原文地址:http://blog.csdn.net/clj198606061111/article/details/20854419

  8. Visual Studio Command Prompt 工具配置方法

    有时候,我们无法找到Visual Studio Command Prompt,需要手动配置 打开 Visual studio2015,选择  "工具"—>"外部工具 ...

  9. 已看1.熟练的使用Java语言进行面向对象程序设计,有良好的编程习惯,熟悉常用的Java API,包括集合框架、多线程(并发编程)、I/O(NIO)、Socket、JDBC、XML、反射等。[泛型]\

    1.熟练的使用Java语言进行面向对象程序设计,有良好的编程习惯,熟悉常用的Java API,包括集合框架.多线程(并发编程).I/O(NIO).Socket.JDBC.XML.反射等.[泛型]\1* ...

  10. Spring 第一天课程

    一. 面试题部分 1. 什么是IOC?什么是DI?他们有什么区别? 答案: IOC,即控制反转.是指将原来程序中自己创建实现类对象的控制权反转到IOC容器中. IOC的别名:依赖注入(DI),DI 是 ...