fork(1) download
  1. n, k = map(int, input().split())
  2. numbers = input()
  3.  
  4. arr = []
  5. for number in numbers:
  6. while arr and 0 < k:
  7. if arr[-1] < number:
  8. arr.pop()
  9. k -= 1
  10. else:
  11. break
  12. arr.append(number)
  13.  
  14. print("".join(arr))
  15.  
Success #stdin #stdout 0.03s 9772KB
stdin
5 1
54321
stdout
54321