#include<bits/stdc++.h>
using namespace std;
stack<char> st;
char b[3000005];
int main(){
int n,m;
string b;
cin>>n>>m;
cin>>b;
int dx=0;
int sum=0;
string ans="";
for(int i=0;i<n;i++){
while(!st.empty()&&st.top()<b[i]){
if(sum==m){
break;
}
st.pop();
sum++;
}
st.push(b[i]);
}
while(!st.empty()){
ans+=st.top();
st.pop();
}
reverse(ans.begin(),ans.end());
cout<<ans;
return 0;
}78
文章信息与版本
文章信息
- 收录
- 2026年2月28日
- 更新
- 2026年2月28日
- 篇幅
- 约 1 分钟