Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- string s;
- int steve[100001],vf;
- int main()
- {
- #ifdef HOME
- freopen("test.in","r",stdin);
- freopen("test.out","w",stdout);
- #endif // HOME
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int n,k,i;
- cin>>n>>k>>s;
- for(i=0; i<n; i++)
- {
- while(k&&vf>(s[i]=='0')&&s[i]-'0'<steve[vf])
- {
- vf--;
- k--;
- }
- if(k>=vf&&steve[vf]==0&&s[i]-'0'<steve[1]&&s[i]!='0')
- {
- k-=vf;
- vf=0;
- }
- steve[++vf]=s[i]-'0';
- }
- while(k&&vf)
- {
- k--;
- vf--;
- }
- for(i=1; i<=vf; i++)
- cout<<steve[i];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement