fork download
  1. /*
  2. Coder: __turing__
  3. Tran Van Nam - Chuyen Tin Nguyen Trai High School - Quang Binh
  4. */
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7.  
  8. #define file(name) if (fopen(name".INP", "r")){freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout);}
  9.  
  10. int p = 0;
  11. char Stack[10000007];
  12.  
  13. signed main(){
  14. ios_base::sync_with_stdio(0);
  15. cin.tie(0); cout.tie(0);
  16.  
  17. file("TEST");
  18.  
  19. string s; int k;
  20. cin >> s >> k;
  21. for (int i = 0; i < (int)s.length(); i++)
  22. if (p == 0) Stack[++p] = s[i];
  23. else{
  24. while (p > 0 && k > 0 && Stack[p] < s[i]) p--, k--;
  25. Stack[++p] = s[i];
  26. }
  27. while (p > 0 && k > 0) p--, k--;
  28. string ans = "";
  29. for (int i = 1; i <= p; i++) ans += Stack[i];
  30. p = 0;
  31. while (p < (int)ans.length()-1 && ans[p] == '0') p++;
  32. for (; p < (int)ans.length(); p++) cout << ans[p];
  33.  
  34. return 0^0;
  35. }
Success #stdin #stdout 0.01s 5436KB
stdin
Standard input is empty
stdout
Standard output is empty