Codeforces 581C Developing Skills
来源:互联网 发布:北京理光软件研究所 编辑:程序博客网 时间:2024/05/23 11:04
这是一道简单的贪心,我们将每一个数字按照最后一位的大小排一个序,然后优先加给最后一位大的,如果有多的那么就分给每一个,然是不能超过100
#include<cstdio>#include<iostream>#include<algorithm>using namespace std;#define MAXN 100005int a[MAXN], n, k, sum;inline bool cmp(const int a, const int b){ return (a % 10) > (b % 10);}int main(){ scanf("%d%d", &n, &k); for(int i = 1; i <= n; i ++) { scanf("%d", &a[i]); sum += a[i]/10; } sort(a + 1, a + n + 1, cmp); int ans = 0; for(int i = 1; i <= n; i ++) { k -= 10 - (a[i]%10); if(k >= 0) ++ ans; else break; } ans += sum; if(k) ans += min(n * 10 - ans, k/10); ans = min(ans, n * 10); printf("%d\n", ans); return 0;}
0 0
- Codeforces 581C Developing Skills
- codeforces 581C Developing Skills
- codeforces 581C Developing Skills
- CodeForces 581C Developing Skills
- Codeforces-581C-Developing Skills
- Codeforces 581C Developing Skills 贪心
- CodeForces 581C - Developing Skills(模拟)
- codeforces 581-C. Developing Skills(贪心)
- 解题报告 之 CodeForces 581C Developing Skills
- CF 581C Developing Skills
- coderforce 581C. Developing Skills
- Codeforces Round #322 C Developing Skills
- codefoces 581C Developing Skills(贪心)
- Codeforces Round #322 (Div. 2)C. Developing Skills
- Codeforces Round #322 (Div. 2)C. Developing Skills
- cf 591 C. Developing Skills
- Code Forces 581 C. Developing Skills(贪心)
- Developing Skills
- 浏览器常见HTTP错误代码
- c语言学习笔记(9)优先级及类型转换分析
- 随感 。 2015.09.28
- HTTP协议
- POJ - 3666 Making the Grade(DP)
- Codeforces 581C Developing Skills
- SpringMVC获取静态资源的问题
- Linux的capability深入分析
- 如何在十天内掌握线性代数
- Cocos studio 2.3.2 Python exec is not exist.
- git管理,终端常用命令
- 第一阶段的总结
- URAL 1104(数论)
- 深入 HBase 架构解析(2)