引子:

A题过于简单导致不敢提交,拖拖拉拉10多分钟还是决定交,太冲动交错了CE一发,我就知道又要错过一次涨分的机会....

B题还是过了,根据题意目测数组大小开1e5,居然蒙对,感觉用vector更好一点...

C题WA第9组,GG思密达....明天起床再补C吧 - -

题目链接:

http://codeforces.com/contest/835/problem/B

B. The number on the board

Some natural number was written on the board. Its sum of digits was not less than k. But you were distracted a bit, and someone changed this number to n, replacing some digits with others. It's known that the length of the number didn't change.

You have to find the minimum number of digits in which these two numbers can differ.

Input

The first line contains integer k (1 ≤ k ≤ 109).

The second line contains integer n (1 ≤ n < 10100000).

There are no leading zeros in n. It's guaranteed that this situation is possible.

Output

Print the minimum number of digits in which the initial number and n can differ.

Examples

input

3
11

output

1

input

3
99

output

0

Note

In the first example, the initial number could be 12.

In the second example the sum of the digits of n is not less than k. The initial number could be equal to n.

解题思路:

由于题目过短题意就不说了,其实,具体思路看代码吧!

AC代码:

#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <string.h>
#include <iostream>
#include<algorithm>
#include <queue>
#include <vector>
#include <cmath>
#include<string>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=1e5+;
#define lrt (rt*2)
#define rrt (rt*2+1)
#define LL long long
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define exp 1e-8
#define For(i,n) for(int i=0;i<n;i++)
//************************************************63
char a[maxn];
LL b[maxn];
int main()
{
LL n,sum=,k=,ans=;
scanf("%I64d %s",&n,a);
for(LL i=;a[i]!='\0';i++)
{
b[k]=a[i]-'';
sum+=b[k];
k++;
}
sort(b,b+k);
while(sum<n)
{
sum+=(-b[ans]);
ans++;
}
cout<<ans<<endl;
return ;
}

Codeforces Round #427 (Div. 2) B. The number on the board的更多相关文章

  1. CodeForces 835C - Star sky | Codeforces Round #427 (Div. 2)

    s <= c是最骚的,数组在那一维开了10,第八组样例直接爆了- - /* CodeForces 835C - Star sky [ 前缀和,容斥 ] | Codeforces Round #4 ...

  2. CodeForces 835D - Palindromic characteristics | Codeforces Round #427 (Div. 2)

    证明在Tutorial的评论版里 /* CodeForces 835D - Palindromic characteristics [ 分析,DP ] | Codeforces Round #427 ...

  3. Codeforces Round #427 (Div. 2)—A,B,C,D题

    A. Key races 题目链接:http://codeforces.com/contest/835/problem/A 题目意思:两个比赛打字,每个人有两个参数v和t,v秒表示他打每个字需要多久时 ...

  4. Codeforces Round #427 (Div. 2)

    B. The number on the board 题意: 有一个数字,它的每个数位上的数字的和不小于等于k.现在他改变了若干位,变成了一个新的数n,问现在的数和原来的数最多有多少位不同. 思路: ...

  5. Codeforces Round #427 (Div. 2) Problem B The number on the board (Codeforces 835B) - 贪心

    Some natural number was written on the board. Its sum of digits was not less than k. But you were di ...

  6. 【Codeforces Round #427 (Div. 2) B】The number on the board

    [Link]:http://codeforces.com/contest/835 [Description] 原本有一个数字x,它的各个数码的和原本是>=k的; 现在这个数字x,在不改变位数的情 ...

  7. Codeforces Round #427 (Div. 2) Problem D Palindromic characteristics (Codeforces 835D) - 记忆化搜索

    Palindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th nu ...

  8. Codeforces Round #427 (Div. 2) Problem C Star sky (Codeforces 835C) - 前缀和

    The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinat ...

  9. Codeforces Round #427 (Div. 2) Problem A Key races (Codeforces 835 A)

    Two boys decided to compete in text typing on the site "Key races". During the competition ...

随机推荐

  1. OpenSSL编程

    简介 OpenSSL是一个功能丰富且自包含的开源安全工具箱.它提供的主要功能有:SSL协议实现(包括SSLv2.SSLv3和TLSv1).大量软算法(对称/非对称/摘要).大数运算.非对称算法密钥生成 ...

  2. HDOJ1242 Rescue(营救) 搜索

    Rescue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  3. Geodetic集合

    图G是一个无向连通图,没有自环,并且两点之间至多只有一条边.我们定义顶点v,u最短路径就是从v到u经过边最少的路径.所有包含在v-u的最短路径上的顶点被称为v-u的Geodetic顶点,这些顶点的集合 ...

  4. laravel表单提交

    1.控制器->路由->视图 2.视图 3.控制器

  5. 【Log】logback的配置和使用(一)

    logback介绍 Logback是由log4j创始人设计的又一个开源日志组件.logback当前分成三个模块:logback-core,logback- classic和logback-access ...

  6. PHP 用 ZipArchive 打包指定文件到zip供用户下载

    Ubuntu需安装zlib sudo apt-get install ruby sudo apt-get install zlib1g zlib1g.dev   Windows需开启php_zip.d ...

  7. Java代码实现依赖注入

    http://zhangjunhd.blog.51cto.com/113473/126545 这里将模仿Spring实现一种基于xml配置文件的依赖注入机制.文件中将实现3中注入,一是单值注入,包括i ...

  8. 使用WebUploader客户端批量上传图片,后台使用springMVC接收实例

    使用WebUploader客户端批量上传图片,后台使用springMVC接收实例 我是搞Java后台的,因为最近主管让用webUploader写客户端,但是在网上找了很多,能够复制就能用的并没有几个, ...

  9. 22. Valuing Water 珍惜水资源

    . Valuing Water 珍惜水资源 ① Humanity uses a little less than half the water available worldwide.Yet occu ...

  10. C++和Python混合编程

    为何人工智能(AI)首选Python?读完这篇文章你就知道了:https://blog.csdn.net/qq_41769259/article/details/79419322 C++调用Pytho ...