← Back to List

2812번: 크게 만들기 ↗

Solutions

Python 3
307 B | 307 chars
n,k = map(int,input().split())
L = list(map(int,list(input())))
stk = []
cnt = 0
for i in L:
    while len(stk) > 0 and stk[-1] < i and cnt < k:
        stk.pop()
        cnt +=1
    stk.append(i)

while len(stk) > 0 and stk[-1] < 10 and cnt < k:
    stk.pop()
    cnt +=1

for i in stk:
    print(i,end="")