Advertisement
a53

minlex

a53
Oct 23rd, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #define Nmax 1000001
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int k;
  9. char cuv[Nmax],st[Nmax];
  10. cin>>k>>cuv;
  11. unsigned int L=strlen(cuv);
  12. int vf=0;
  13. for(unsigned int i=0;i<L;++i)
  14. {
  15. while(vf&&k&&st[vf]>cuv[i])
  16. --vf,--k;
  17. st[++vf]=cuv[i];
  18. }
  19. vf-=k;
  20. st[vf+1]=0;
  21. cout<<st+1;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement