Codeforces 835B The number on the board (贪心)
来源:互联网 发布:php选择题答题系统 编辑:程序博客网 时间:2024/06/07 04:13
题目链接
CF 835B
题目大意
分析
代码
#include <bits/stdc++.h>using namespace std;int num[100010];int main(){ string ch; int k,ans,len,i,cnt,p,t; cin>>k; cin>>ch; len=ch.length(); cnt=0; for (i=0;i<len;i++) cnt+=(ch[i]-'0'); if (cnt>=k) cout<<0<<endl; else { p=k-cnt; for (i=0;i<len;i++) num[i]=9-ch[i]+'0'; sort(num,num+len); t=len-1; ans=0; while (p>0) { p-=num[t--]; ans++; } cout<<ans<<endl; } return 0;}
阅读全文
0 0
- CodeForces 835 B.The number on the board(贪心)
- Codeforces 835B The number on the board (贪心)
- (贪心)Codeforces Round #427 B. The number on the board
- codeforces B. The number on the board
- codeforces 835B The number on the board (优先队列,贪心)
- Codeforces 835B-The number on the board
- Codeforces #835B: The Number on the Board 题解
- Codeforces 835 B The number on the board
- Codeforces 835 B The number on the board
- CodeForces 835B The number on the board
- codeforces 835b The number on the board
- codeforces 835B The number on the board
- codeforces 835b 之 The number on the board
- codeforces 835B The number on the board
- Codeforces-The number on the board
- B. The number on the board
- Codeforces Round #427 (Div. 2) B. The number on the board
- Codeforces Round #427 (Div. 2)-B. The number on the board
- 【TX1学习与开发系列】如何快速部署多个tx1系统(超细节版)(五)
- servlet中文乱码问题总结
- JAVA第一天
- 数据结构-队列
- python之全局变量操作
- Codeforces 835B The number on the board (贪心)
- conda命令行使用
- JAVA第二天
- 2017"百度之星"程序设计大赛
- angular动态渲染问题
- 推荐:Zookeeper 开源客户端框架Curator简介
- linux 服务器 中脚本启动关闭 jar
- LeetCode之Remove Element
- visio studio提高工作效率的十个小技巧