Codeforces 835B - The number on the board Solution
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///AH Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- int main()
- {
- ll n,k,i,ss=0,r=0;
- string s;
- cin>>k>>s;
- sort(s.begin(),s.end());
- for(i=0;i<s.size();i++)
- ss+=s[i]-'0';
- for(i=0;i<s.size();i++)
- {
- if(ss>=k)
- break;
- while(s[i]<'9')
- {
- ss++;
- s[i]++;
- }
- r++;
- }
- cout<<r<<endl;
- }
No comments